go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
itkGPUResampleImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright UMC Utrecht and contributors
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 #ifndef __itkGPUResampleImageFilter_h
19 #define __itkGPUResampleImageFilter_h
20 
21 #include "itkResampleImageFilter.h"
22 
27 #include "itkGPUTransformBase.h"
29 
30 namespace itk
31 {
33 itkGPUKernelClassMacro( GPUResampleImageFilterKernel );
34 
46 template< typename TInputImage, typename TOutputImage, typename TInterpolatorPrecisionType = float >
47 class ITK_EXPORT GPUResampleImageFilter :
48  public GPUImageToImageFilter< TInputImage, TOutputImage,
49  ResampleImageFilter< TInputImage, TOutputImage, TInterpolatorPrecisionType > >
50 {
51 public:
52 
55  typedef ResampleImageFilter<
56  TInputImage, TOutputImage, TInterpolatorPrecisionType > CPUSuperclass;
57  typedef GPUImageToImageFilter<
58  TInputImage, TOutputImage, CPUSuperclass > GPUSuperclass;
60  typedef SmartPointer< const Self > ConstPointer;
61 
63  itkNewMacro( Self );
64 
66  itkTypeMacro( GPUResampleImageFilter, GPUSuperclass );
67 
69  itkStaticConstMacro( InputImageDimension, unsigned int,
70  TInputImage::ImageDimension );
71  itkStaticConstMacro( OutputImageDimension, unsigned int,
72  TOutputImage::ImageDimension );
73 
75  typedef TInputImage InputImageType;
76  typedef TOutputImage OutputImageType;
79  typedef TInterpolatorPrecisionType InterpolatorPrecisionType;
80 
82  typedef typename CPUSuperclass::InterpolatorType InterpolatorType;
83  typedef typename CPUSuperclass::TransformType TransformType;
84  typedef typename CPUSuperclass::ExtrapolatorType ExtrapolatorType;
85  typedef typename CPUSuperclass::InputImageRegionType InputImageRegionType;
86  typedef typename CPUSuperclass::OutputImageRegionType OutputImageRegionType;
87  typedef typename CPUSuperclass::SizeType SizeType;
88  typedef typename CPUSuperclass::IndexType IndexType;
89 
91 
96  InterpolatorPrecisionType, InputImageDimension > CompositeTransformBaseType;
97 
99  typedef GPUBSplineInterpolateImageFunction< InputImageType,
100  InterpolatorPrecisionType > GPUBSplineInterpolatorType;
104 
106  typedef GPUBSplineBaseTransform<
107  InterpolatorPrecisionType, InputImageDimension > GPUBSplineBaseTransformType;
108 
110  virtual void SetInterpolator( InterpolatorType * _arg );
111 
113  virtual void SetExtrapolator( ExtrapolatorType * _arg );
114 
116  virtual void SetTransform( const TransformType * _arg );
117 
120  itkSetMacro( RequestedNumberOfSplits, unsigned int );
121  itkGetConstMacro( RequestedNumberOfSplits, unsigned int );
122 
123 protected:
124 
127  virtual void PrintSelf( std::ostream & os, Indent indent ) const ITK_OVERRIDE;
128 
129  virtual void GPUGenerateData( void );
130 
131  // Supported GPU transform types
132  typedef enum {
133  IdentityTransform = 1,
137  Else
138  } GPUTransformTypeEnum;
139 
141  void SetArgumentsForPreKernelManager(
142  const typename GPUOutputImage::Pointer & output );
143 
145  void SetArgumentsForLoopKernelManager(
146  const typename GPUInputImage::Pointer & input,
147  const typename GPUOutputImage::Pointer & output );
148 
150  void SetTransformParametersForLoopKernelManager(
151  const std::size_t transformIndex );
152 
154  void SetArgumentsForPostKernelManager(
155  const typename GPUInputImage::Pointer & input,
156  const typename GPUOutputImage::Pointer & output );
157 
159  void SetBSplineTransformCoefficientsToGPU(
160  const std::size_t transformIndex );
161 
163  const GPUTransformTypeEnum GetTransformType( const int & transformIndex ) const;
164 
166  bool HasTransform( const GPUTransformTypeEnum type ) const;
167 
169  int GetTransformHandle( const GPUTransformTypeEnum type ) const;
170 
172  bool GetKernelIdFromTransformId(
173  const std::size_t & index, std::size_t & kernelId ) const;
174 
176  GPUBSplineBaseTransformType * GetGPUBSplineBaseTransform(
177  const std::size_t transformIndex );
178 
179 private:
180 
181  GPUResampleImageFilter( const Self & ); // purposely not implemented
182  void operator=( const Self & ); // purposely not implemented
183 
186 
187  GPUDataManagerPointer m_InputGPUImageBase;
188  GPUDataManagerPointer m_OutputGPUImageBase;
189  GPUDataManagerPointer m_FilterParameters;
190  GPUDataManagerPointer m_DeformationFieldBuffer;
192 
193  typedef std::pair< int, bool > TransformHandle;
194  typedef std::map< GPUTransformTypeEnum, TransformHandle > TransformsHandle;
195 
196 #if 0
197  class TransformKernelHelper
198  {
199  GPUTransformTypeEnum m_TransformType;
200  std::string m_TransformTypeAsString;
201  std::: size_t m_TransformKernelHandle;
202  bool m_Compiled;
203  TransformKernelHelper()
204  {
205  m_TransformType = GPUResampleImageFilter::Else;
206  m_TransformTypeAsString = "Else";
207  m_TransformKernelHandle = 0; // ??
208  m_Compiled = false;
209  }
210 
211 
212  };
213 
214  std::vector< TransformKernelHelper > m_SupportedTransformKernels;
215 #endif
216 
217  std::vector< std::string > m_Sources;
218  std::size_t m_SourceIndex;
219 
222 
225 
227  TransformsHandle m_FilterLoopGPUKernelHandle;
229 
230  // GPU kernel managers
231  GPUKernelManagerPointer m_PreKernelManager;
232  GPUKernelManagerPointer m_LoopKernelManager;
233  GPUKernelManagerPointer m_PostKernelManager;
234 };
235 
236 } // end namespace itk
237 
238 #ifndef ITK_MANUAL_INSTANTIATION
239 #include "itkGPUResampleImageFilter.hxx"
240 #endif
241 
242 #endif /* __itkGPUResampleImageFilter_h */
GPUDataManagerPointer m_DeformationFieldBuffer
GPUTraits< TInputImage >::Type GPUInputImage
class to abstract the behaviour of the GPU filters.
GPUCompositeTransformBase< InterpolatorPrecisionType, InputImageDimension > CompositeTransformBaseType
GPUImageToImageFilter< TInputImage, TOutputImage, CPUSuperclass > GPUSuperclass
ResampleImageFilter< TInputImage, TOutputImage, TInterpolatorPrecisionType > CPUSuperclass
Base class for all GPU transforms.
GPUKernelManagerPointer m_PostKernelManager
GPUBSplineInterpolatorType::GPUCoefficientImageType GPUBSplineInterpolatorCoefficientImageType
CPUSuperclass::IndexType IndexType
itkGPUKernelClassMacro(GPUBSplineTransformKernel)
std::vector< std::string > m_Sources
GPU base class for the BSplineTransform.
GPUDataManagerPointer m_OutputGPUImageBase
TInterpolatorPrecisionType InterpolatorPrecisionType
GPUDataManager::Pointer GPUDataManagerPointer
CPUSuperclass::ExtrapolatorType ExtrapolatorType
GPUInterpolatorBase * m_InterpolatorBase
GPU version of ResampleImageFilter.
GPUBSplineInterpolateImageFunction< InputImageType, InterpolatorPrecisionType > GPUBSplineInterpolatorType
Templated n-dimensional image class for the GPU.
Definition: itkGPUImage.h:63
CPUSuperclass::TransformType TransformType
GPUBSplineBaseTransform< InterpolatorPrecisionType, InputImageDimension > GPUBSplineBaseTransformType
GPU version of BSplineInterpolateImageFunction.
OpenCLKernelManager::Pointer GPUKernelManagerPointer
GPUKernelManagerPointer m_PreKernelManager
GPUBSplineInterpolatorType::GPUCoefficientImagePointer GPUBSplineInterpolatorCoefficientImagePointer
std::map< GPUTransformTypeEnum, TransformHandle > TransformsHandle
std::pair< int, bool > TransformHandle
CPUSuperclass::InterpolatorType InterpolatorType
CPUSuperclass::OutputImageRegionType OutputImageRegionType
CPUSuperclass::InputImageRegionType InputImageRegionType
GPUDataManagerPointer m_FilterParameters
GPUKernelManagerPointer m_LoopKernelManager
GPUBSplineInterpolatorType::GPUDataManagerPointer GPUBSplineInterpolatorDataManagerPointer
Base class fro all GPU interpolators.
GPUDataManagerPointer m_InputGPUImageBase
GPUSuperclass::OutputImagePixelType OutputImagePixelType
SmartPointer< const Self > ConstPointer
GPUTraits< TOutputImage >::Type GPUOutputImage
Superclass::OutputImagePixelType OutputImagePixelType


Generated on 04-09-2015 for elastix by doxygen 1.8.9.1 elastix logo