RTK  2.0.0
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:
62 
64  typedef ProjectionStackType VolumeType;
65  typedef enum {FP_UNKNOWN=-1,
66  FP_JOSEPH=0,
67  FP_CUDARAYCAST=2,
68  FP_JOSEPHATTENUATED=3} ForwardProjectionType;
69  typedef enum {BP_UNKNOWN=-1,
70  BP_VOXELBASED=0,
71  BP_JOSEPH=1,
72  BP_CUDAVOXELBASED=2,
73  BP_CUDARAYCAST=4,
74  BP_JOSEPHATTENUATED=5} BackProjectionType;
75 
81 
83  itkNewMacro(Self)
84 
85 
87 
89  virtual void SetForwardProjectionFilter (ForwardProjectionType fwtype);
90  ForwardProjectionType GetForwardProjectionFilter () { return m_CurrentForwardProjectionConfiguration; }
91  virtual void SetBackProjectionFilter (BackProjectionType bptype);
92  BackProjectionType GetBackProjectionFilter () { return m_CurrentBackProjectionConfiguration; }
94 
95 protected:
97  virtual ~IterativeConeBeamReconstructionFilter() ITK_OVERRIDE {}
98 
101  virtual BackProjectionPointerType InstantiateBackProjectionFilter (int bptype);
102 
105  virtual ForwardProjectionPointerType InstantiateForwardProjectionFilter (int fwtype);
106 
111 
114  template < typename ImageType >
115  using EnableCudaScalarAndVectorType = typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&
116  std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value &&
118  itk::PixelTraits<typename ImageType::PixelType>::Dimension == 3 ) >::type;
119  template < typename ImageType >
120  using DisableCudaScalarAndVectorType = typename std::enable_if< std::is_same< CPUImageType, ImageType >::value ||
121  !std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value ||
122  ( itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 &&
123  itk::PixelTraits<typename ImageType::PixelType>::Dimension != 3 ) >::type;
124  template < typename ImageType >
125  using EnableCudaScalarType = typename std::enable_if< !std::is_same< CPUImageType, ImageType >::value &&
126  std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value &&
127  itk::PixelTraits<typename ImageType::PixelType>::Dimension == 1 >::type;
128  template < typename ImageType >
129  using DisableCudaScalarType = typename std::enable_if< std::is_same< CPUImageType, ImageType >::value ||
130  !std::is_same< typename itk::PixelTraits<typename ImageType::PixelType>::ValueType, float >::value ||
131  itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 >::type;
132  template < typename ImageType >
133  using EnableVectorType = typename std::enable_if< itk::PixelTraits<typename ImageType::PixelType>::Dimension != 1 >::type;
134  template < typename ImageType >
135  using DisableVectorType = typename std::enable_if< itk::PixelTraits<typename ImageType::PixelType>::Dimension == 1 >::type;
137 
138  template < typename ImageType, EnableCudaScalarAndVectorType<ImageType>* = ITK_NULLPTR >
139  ForwardProjectionPointerType InstantiateCudaForwardProjection()
140  {
141  ForwardProjectionPointerType fw;
142 #ifdef RTK_USE_CUDA
143  fw = CudaForwardProjectionImageFilter<ImageType, ImageType>::New();
144 #endif
145  return fw;
146  }
147 
148 
149  template < typename ImageType, DisableCudaScalarAndVectorType<ImageType>* = ITK_NULLPTR >
150  ForwardProjectionPointerType InstantiateCudaForwardProjection()
151  {
152  itkGenericExceptionMacro(<< "CudaRayCastBackProjectionImageFilter only available with 3D CudaImage of float or itk::Vector<float,3>.");
153  return ITK_NULLPTR;
154  }
155 
156 
157  template < typename ImageType, EnableVectorType<ImageType>* = ITK_NULLPTR >
158  ForwardProjectionPointerType InstantiateJosephForwardAttenuatedProjection()
159  {
160  itkGenericExceptionMacro(<< "JosephForwardAttenuatedProjectionImageFilter only available with scalar pixel types.");
161  return ITK_NULLPTR;
162  }
163 
164 
165  template < typename ImageType, DisableVectorType<ImageType>* = ITK_NULLPTR >
166  ForwardProjectionPointerType InstantiateJosephForwardAttenuatedProjection()
167  {
168  ForwardProjectionPointerType fw;
170  return fw;
171  }
172 
173 
174  template < typename ImageType, EnableCudaScalarAndVectorType<ImageType>* = ITK_NULLPTR >
175  BackProjectionPointerType InstantiateCudaBackProjection()
176  {
177  BackProjectionPointerType bp;
178 #ifdef RTK_USE_CUDA
179  bp = CudaBackProjectionImageFilter<ImageType>::New();
180 #endif
181  return bp;
182  }
183 
184 
185  template < typename ImageType, DisableCudaScalarAndVectorType<ImageType>* = ITK_NULLPTR >
186  BackProjectionPointerType InstantiateCudaBackProjection()
187  {
188  itkGenericExceptionMacro(<< "CudaBackProjectionImageFilter only available with 3D CudaImage of float or itk::Vector<float,3>.");
189  return ITK_NULLPTR;
190  }
191 
192 
193  template < typename ImageType, EnableCudaScalarType<ImageType>* = ITK_NULLPTR >
194  BackProjectionPointerType InstantiateCudaRayCastBackProjection()
195  {
196  BackProjectionPointerType bp;
197 #ifdef RTK_USE_CUDA
198  bp = CudaRayCastBackProjectionImageFilter::New();
199 #endif
200  return bp;
201  }
202 
203 
204  template < typename ImageType, DisableCudaScalarType<ImageType>* = ITK_NULLPTR >
205  BackProjectionPointerType InstantiateCudaRayCastBackProjection()
206  {
207  itkGenericExceptionMacro(<< "CudaRayCastBackProjectionImageFilter only available with 3D CudaImage of float.");
208  return ITK_NULLPTR;
209  }
210 
211 
212  template < typename ImageType, EnableVectorType<ImageType>* = ITK_NULLPTR >
213  BackProjectionPointerType InstantiateJosephBackAttenuatedProjection()
214  {
215  itkGenericExceptionMacro(<< "JosephBackAttenuatedProjectionImageFilter only available with scalar pixel types.");
216  return ITK_NULLPTR;
217  }
218 
219 
220  template < typename ImageType, DisableVectorType<ImageType>* = ITK_NULLPTR >
221  BackProjectionPointerType InstantiateJosephBackAttenuatedProjection()
222  {
223  BackProjectionPointerType bp;
225  return bp;
226  }
227 
228 private:
229  //purposely not implemented
231  void operator=(const Self&);
232 }; // end of class
233 
234 } // end namespace rtk
235 
236 #ifndef ITK_MANUAL_INSTANTIATION
237 #include "rtkIterativeConeBeamReconstructionFilter.hxx"
238 #endif
239 
240 #endif
rtk::BackProjectionImageFilter< ProjectionStackType, VolumeType > BackProjectionFilterType
Base class for forward projection, i.e. accumulation along x-ray lines.
itk::Image< typename ProjectionStackType::PixelType, ProjectionStackType::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 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
rtk::ForwardProjectionImageFilter< VolumeType, ProjectionStackType > ForwardProjectionFilterType
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
itk::ImageToImageFilter< TOutputImage, TOutputImage > Superclass