ITK  4.8.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 >
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 
81 
85  typedef typename FixedImageType::IndexType IndexType;
86  typedef typename FixedImageType::SizeType SizeType;
87  typedef typename FixedImageType::SpacingType SpacingType;
88 
93 
95  itkStaticConstMacro(ImageDimension, unsigned
97 
99  typedef typename Superclass::PixelType PixelType;
104 
106  typedef double CoordRepType;
111 
114 
118 
124 
127 
129  itkGetOpenCLSourceFromKernelMacro(GPUDemonsRegistrationFunctionKernel);
130 
133  {
135  }
136 
139  {
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,
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  {
207  }
208  virtual bool GetUseMovingImageGradient() const
209  {
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  GPUDemonsRegistrationFunction(const Self &); //purposely not implemented
245  void operator=(const Self &); //purposely not implemented
246 
248  //SpacingType m_FixedImageSpacing;
249  //PointType m_FixedImageOrigin;
251  double m_Normalizer;
252 
255 
259 
262 
265 
268 
271 
275  mutable double m_Metric;
276  mutable double m_SumOfSquaredDifference;
278  mutable double m_RMSChange;
279  mutable double m_SumOfSquaredChange;
280 
284 
287 
288 };
289 } // end namespace itk
290 
291 #ifndef ITK_MANUAL_INSTANTIATION
292 #include "itkGPUDemonsRegistrationFunction.hxx"
293 #endif
294 
295 #endif
virtual void InitializeIteration() override
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
virtual void ReleaseGlobalDataPointer(void *GlobalData) const override
virtual void GPUComputeUpdate(const DisplacementFieldTypePointer output, DisplacementFieldTypePointer update, void *gd) override
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
virtual void GPUReleaseMetricData() override
CovariantVector< double, itkGetStaticConstMacro(ImageDimension) > CovariantVectorType
MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator
LinearInterpolateImageFunction< MovingImageType, CoordRepType > DefaultInterpolatorType
GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField > Superclass
virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood, void *globalData, const FloatOffsetType &offset=FloatOffsetType(0.0)) override
virtual void GPUAllocateMetricData(unsigned int numPixels) override
virtual double GetIntensityDifferenceThreshold() const
Linearly interpolate an image at specified positions.
CentralDifferenceImageFunction< MovingImageType, CoordRepType > MovingImageGradientCalculatorType
MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
itkGetOpenCLSourceFromKernelMacro(GPUDemonsRegistrationFunctionKernel)
virtual void SetIntensityDifferenceThreshold(double)
Base class for all image interpolaters.
GradientCalculatorType::Pointer GradientCalculatorPointer
Superclass::DisplacementFieldType DisplacementFieldType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
void PrintSelf(std::ostream &os, Indent indent) const override
virtual TimeStepType ComputeGlobalTimeStep(void *) const override
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:51
A templated class holding a n-Dimensional covariant vector.