RTK  2.0.1
Reconstruction Toolkit
rtkIterativeConeBeamReconstructionFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright RTK Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 
19 #ifndef rtkIterativeConeBeamReconstructionFilter_h
20 #define rtkIterativeConeBeamReconstructionFilter_h
21 
22 #include <itkPixelTraits.h>
23 
24 // Forward projection filters
25 #include "rtkConfiguration.h"
27 // Back projection filters
29 
30 #ifdef RTK_USE_CUDA
34 #endif
35 
36 namespace rtk
37 {
38 
51 template<class TOutputImage,
52  class ProjectionStackType=TOutputImage>
54  public itk::ImageToImageFilter<TOutputImage, TOutputImage>
55 {
56 public:
57  ITK_DISALLOW_COPY_AND_ASSIGN(IterativeConeBeamReconstructionFilter);
58 
64 
66  using VolumeType = ProjectionStackType;
67  typedef enum {FP_UNKNOWN=-1,
68  FP_JOSEPH=0,
69  FP_CUDARAYCAST=2,
70  FP_JOSEPHATTENUATED=3} ForwardProjectionType;
71  typedef enum {BP_UNKNOWN=-1,
72  BP_VOXELBASED=0,
73  BP_JOSEPH=1,
74  BP_CUDAVOXELBASED=2,
75  BP_CUDARAYCAST=4,
76  BP_JOSEPHATTENUATED=5} BackProjectionType;
77 
83 
85  itkNewMacro(Self)
86 
87 
89 
91  virtual void SetForwardProjectionFilter (ForwardProjectionType fwtype);
92  ForwardProjectionType GetForwardProjectionFilter () { return m_CurrentForwardProjectionConfiguration; }
93  virtual void SetBackProjectionFilter (BackProjectionType bptype);
94  BackProjectionType GetBackProjectionFilter () { return m_CurrentBackProjectionConfiguration; }
96 
97 protected:
99  ~IterativeConeBeamReconstructionFilter() override = default;
100 
103  virtual BackProjectionPointerType InstantiateBackProjectionFilter (int bptype);
104 
107  virtual ForwardProjectionPointerType InstantiateForwardProjectionFilter (int fwtype);
108 
113 
116  template < typename ImageType >
117  using EnableCudaScalarAndVectorType = typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&
118  std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value &&
120  itk::PixelTraits<typename ImageType::PixelType>::Dimension == 3 ) >::type;
121  template < typename ImageType >
122  using DisableCudaScalarAndVectorType = typename std::enable_if< std::is_same< CPUImageType, ImageType >::value ||
123  !std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value ||
124  ( itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 &&
125  itk::PixelTraits<typename ImageType::PixelType>::Dimension != 3 ) >::type;
126  template < typename ImageType >
127  using EnableCudaScalarType = typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&
128  std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value &&
129  itk::PixelTraits<typename ImageType::PixelType>::Dimension == 1 >::type;
130  template < typename ImageType >
131  using DisableCudaScalarType = typename std::enable_if< std::is_same< CPUImageType, ImageType >::value ||
132  !std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value ||
133  itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 >::type;
134  template < typename ImageType >
135  using EnableVectorType = typename std::enable_if< itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 >::type;
136  template < typename ImageType >
137  using DisableVectorType = typename std::enable_if< itk::PixelTraits<typename ImageType::PixelType>::Dimension == 1 >::type;
139 
140  template < typename ImageType, EnableCudaScalarAndVectorType<ImageType>* = nullptr >
142  {
144 #ifdef RTK_USE_CUDA
145  fw = CudaForwardProjectionImageFilter<ImageType, ImageType>::New();
146 #endif
147  return fw;
148  }
149 
150 
151  template < typename ImageType, DisableCudaScalarAndVectorType<ImageType>* = nullptr >
153  {
154  itkGenericExceptionMacro(<< "CudaRayCastBackProjectionImageFilter only available with 3D CudaImage of float or itk::Vector<float,3>.");
155  return nullptr;
156  }
157 
158 
159  template < typename ImageType, EnableVectorType<ImageType>* = nullptr >
161  {
162  itkGenericExceptionMacro(<< "JosephForwardAttenuatedProjectionImageFilter only available with scalar pixel types.");
163  return nullptr;
164  }
165 
166 
167  template < typename ImageType, DisableVectorType<ImageType>* = nullptr >
169  {
172  return fw;
173  }
174 
175 
176  template < typename ImageType, EnableCudaScalarAndVectorType<ImageType>* = nullptr >
178  {
180 #ifdef RTK_USE_CUDA
181  bp = CudaBackProjectionImageFilter<ImageType>::New();
182 #endif
183  return bp;
184  }
185 
186 
187  template < typename ImageType, DisableCudaScalarAndVectorType<ImageType>* = nullptr >
189  {
190  itkGenericExceptionMacro(<< "CudaBackProjectionImageFilter only available with 3D CudaImage of float or itk::Vector<float,3>.");
191  return nullptr;
192  }
193 
194 
195  template < typename ImageType, EnableCudaScalarType<ImageType>* = nullptr >
197  {
199 #ifdef RTK_USE_CUDA
200  bp = CudaRayCastBackProjectionImageFilter::New();
201 #endif
202  return bp;
203  }
204 
205 
206  template < typename ImageType, DisableCudaScalarType<ImageType>* = nullptr >
208  {
209  itkGenericExceptionMacro(<< "CudaRayCastBackProjectionImageFilter only available with 3D CudaImage of float.");
210  return nullptr;
211  }
212 
213 
214  template < typename ImageType, EnableVectorType<ImageType>* = nullptr >
216  {
217  itkGenericExceptionMacro(<< "JosephBackAttenuatedProjectionImageFilter only available with scalar pixel types.");
218  return nullptr;
219  }
220 
221 
222  template < typename ImageType, DisableVectorType<ImageType>* = nullptr >
224  {
227  return bp;
228  }
229 
230 }; // end of class
231 
232 } // end namespace rtk
233 
234 #ifndef ITK_MANUAL_INSTANTIATION
235 #include "rtkIterativeConeBeamReconstructionFilter.hxx"
236 #endif
237 
238 #endif
Base class for forward projection, i.e. accumulation along x-ray lines.
typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&std::is_same< typename itk::PixelTraits< typename ImageType::PixelType >::ValueType, float >::value &&itk::PixelTraits< typename ImageType::PixelType >::Dimension==1 >::type EnableCudaScalarType
typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&std::is_same< typename itk::PixelTraits< typename ImageType::PixelType >::ValueType, float >::value &&(itk::PixelTraits< typename ImageType::PixelType >::Dimension==1||itk::PixelTraits< typename ImageType::PixelType >::Dimension==3) >::type EnableCudaScalarAndVectorType
typename std::enable_if< itk::PixelTraits< typename ImageType::PixelType >::Dimension!=1 >::type EnableVectorType
typename itk::Image< typename TOutputImage::PixelType, TOutputImage::ImageDimension > CPUImageType
typename std::enable_if< std::is_same< CPUImageType, ImageType >::value||!std::is_same< typename itk::PixelTraits< typename ImageType::PixelType >::ValueType, float >::value||itk::PixelTraits< typename ImageType::PixelType >::Dimension!=1 >::type DisableCudaScalarType
Mother class for cone beam reconstruction filters which need runtime selection of their forward and b...
typename std::enable_if< itk::PixelTraits< typename ImageType::PixelType >::Dimension==1 >::type DisableVectorType
typename std::enable_if< std::is_same< CPUImageType, ImageType >::value||!std::is_same< typename itk::PixelTraits< typename ImageType::PixelType >::ValueType, float >::value||(itk::PixelTraits< typename ImageType::PixelType >::Dimension!=1 &&itk::PixelTraits< typename ImageType::PixelType >::Dimension!=3) >::type DisableCudaScalarAndVectorType