ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkGPUDemonsRegistrationFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software 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 #ifndef itkGPUDemonsRegistrationFunction_h
19 #define itkGPUDemonsRegistrationFunction_h
20 
22 #include "itkPoint.h"
25 #include "itkGPUReduction.h"
26 
27 namespace itk
28 {
55 itkGPUKernelClassMacro(GPUDemonsRegistrationFunctionKernel);
56 
57 template< typename TFixedImage, typename TMovingImage, typename TDisplacementField >
58 class ITK_TEMPLATE_EXPORT GPUDemonsRegistrationFunction :
59  public GPUPDEDeformableRegistrationFunction< TFixedImage,
60  TMovingImage,
61  TDisplacementField >
62 {
63 public:
66  typedef GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage,
67  TDisplacementField> Superclass;
70 
72  itkNewMacro(Self);
73 
75  itkTypeMacro(GPUDemonsRegistrationFunction,
77 
79  typedef typename Superclass::MovingImageType MovingImageType;
80  typedef typename Superclass::MovingImagePointer MovingImagePointer;
81 
83  typedef typename Superclass::FixedImageType FixedImageType;
84  typedef typename Superclass::FixedImagePointer FixedImagePointer;
87  typedef typename FixedImageType::SpacingType SpacingType;
88 
90  typedef typename Superclass::DisplacementFieldType DisplacementFieldType;
91  typedef typename Superclass::DisplacementFieldTypePointer
93 
95  itkStaticConstMacro(ImageDimension, unsigned
96  int, Superclass::ImageDimension);
97 
99  typedef typename Superclass::PixelType PixelType;
103  typedef typename Superclass::TimeStepType TimeStepType;
104 
106  typedef double CoordRepType;
111 
114 
118 
124 
127 
129  itkGetOpenCLSourceFromKernelMacro(GPUDemonsRegistrationFunctionKernel);
130 
133  {
134  m_MovingImageInterpolator = ptr;
135  }
136 
139  {
140  return m_MovingImageInterpolator;
141  }
142 
144  virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) )
145  const ITK_OVERRIDE
146  {
147  return m_TimeStep;
148  }
149 
152  virtual void * GetGlobalDataPointer() const ITK_OVERRIDE
153  {
154  GlobalDataStruct *global = new GlobalDataStruct();
155 
156  global->m_SumOfSquaredDifference = 0.0;
157  global->m_NumberOfPixelsProcessed = 0L;
158  global->m_SumOfSquaredChange = 0;
159  return global;
160  }
161 
163  virtual void ReleaseGlobalDataPointer(void *GlobalData) const ITK_OVERRIDE;
164 
167  virtual void GPUAllocateMetricData(unsigned int numPixels) ITK_OVERRIDE;
168 
171  virtual void GPUReleaseMetricData() ITK_OVERRIDE;
172 
174  virtual void InitializeIteration() ITK_OVERRIDE;
175 
178  virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
179  void *globalData,
180  const FloatOffsetType & offset =
181  FloatOffsetType(0.0) ) ITK_OVERRIDE;
182 
183  virtual void GPUComputeUpdate( const DisplacementFieldTypePointer output,
184  DisplacementFieldTypePointer update,
185  void *gd) ITK_OVERRIDE;
186 
190  virtual double GetMetric() const
191  {
192  return m_Metric;
193  }
194 
196  virtual double GetRMSChange() const
197  {
198  return m_RMSChange;
199  }
200 
204  virtual void SetUseMovingImageGradient(bool flag)
205  {
206  m_UseMovingImageGradient = flag;
207  }
208  virtual bool GetUseMovingImageGradient() const
209  {
210  return m_UseMovingImageGradient;
211  }
213 
218  virtual void SetIntensityDifferenceThreshold(double);
219 
220  virtual double GetIntensityDifferenceThreshold() const;
221 
222 protected:
225 
226  void PrintSelf(std::ostream & os, Indent indent) const ITK_OVERRIDE;
227 
231 
238  };
239 
240  /* GPU kernel handle for GPUComputeUpdate */
242 
243 private:
244  ITK_DISALLOW_COPY_AND_ASSIGN(GPUDemonsRegistrationFunction);
245 
247  //SpacingType m_FixedImageSpacing;
248  //PointType m_FixedImageOrigin;
250  double m_Normalizer;
251 
254 
258 
261 
264 
267 
270 
274  mutable double m_Metric;
275  mutable double m_SumOfSquaredDifference;
277  mutable double m_RMSChange;
278  mutable double m_SumOfSquaredChange;
279 
283 
286 
287 };
288 } // end namespace itk
289 
290 #ifndef ITK_MANUAL_INSTANTIATION
291 #include "itkGPUDemonsRegistrationFunction.hxx"
292 #endif
293 
294 #endif
Critical section locking class that can be allocated on the stack.
GPUReduction< float >::Pointer m_GPUSquaredDifference
Light weight base class for most itk classes.
virtual void * GetGlobalDataPointer() const override
CentralDifferenceImageFunction< FixedImageType > GradientCalculatorType
ConstNeighborhoodIterator< FixedImageType > FixedImageNeighborhoodIteratorType
InterpolateImageFunction< MovingImageType, CoordRepType > InterpolatorType
Superclass::MovingImagePointer MovingImagePointer
Calculate the derivative by central differencing.
itkGPUKernelClassMacro(GPUImageOpsKernel)
unsigned long SizeValueType
Definition: itkIntTypes.h:143
Superclass::DisplacementFieldTypePointer DisplacementFieldTypePointer
CovariantVector< double, itkGetStaticConstMacro(ImageDimension) > CovariantVectorType
MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator
LinearInterpolateImageFunction< MovingImageType, CoordRepType > DefaultInterpolatorType
GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField > Superclass
Linearly interpolate an image at specified positions.
CentralDifferenceImageFunction< MovingImageType, CoordRepType > MovingImageGradientCalculatorType
MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
Base class for all image interpolaters.
GradientCalculatorType::Pointer GradientCalculatorPointer
Superclass::DisplacementFieldType DisplacementFieldType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
virtual TimeStepType ComputeGlobalTimeStep(void *) const override
A templated class holding a n-Dimensional covariant vector.