ITK  4.3.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< class TFixedImage, class TMovingImage, class 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 
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;
85  typedef typename FixedImageType::IndexType IndexType;
86  typedef typename FixedImageType::SizeType SizeType;
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 
132  void SetMovingImageInterpolator(InterpolatorType *ptr)
133  {
134  m_MovingImageInterpolator = ptr;
135  }
136 
138  InterpolatorType * GetMovingImageInterpolator(void)
139  {
140  return m_MovingImageInterpolator;
141  }
142 
144  virtual TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) )
145  const
146  {
147  return m_TimeStep;
148  }
149 
152  virtual void * GetGlobalDataPointer() const
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;
164 
167  virtual void GPUAllocateMetricData(unsigned int numPixels);
168 
171  virtual void GPUReleaseMetricData();
172 
174  virtual void InitializeIteration();
175 
178  virtual PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
179  void *globalData,
180  const FloatOffsetType & offset =
181  FloatOffsetType(0.0) );
182 
183  virtual void GPUComputeUpdate( const DisplacementFieldTypePointer output,
184  DisplacementFieldTypePointer update,
185  void *gd);
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;
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
296