ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkDemonsRegistrationFunction.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 itkDemonsRegistrationFunction_h
19 #define itkDemonsRegistrationFunction_h
20 
22 #include "itkPoint.h"
25 #include <mutex>
26 
27 namespace itk
28 {
53 template< typename TFixedImage, typename TMovingImage, typename TDisplacementField >
54 class ITK_TEMPLATE_EXPORT DemonsRegistrationFunction:
55  public PDEDeformableRegistrationFunction< TFixedImage,
56  TMovingImage,
57  TDisplacementField >
58 {
59 public:
60  ITK_DISALLOW_COPY_AND_ASSIGN(DemonsRegistrationFunction);
61 
64  using Superclass = PDEDeformableRegistrationFunction< TFixedImage,
65  TMovingImage, TDisplacementField >;
68 
70  itkNewMacro(Self);
71 
73  itkTypeMacro(DemonsRegistrationFunction,
75 
77  using MovingImageType = typename Superclass::MovingImageType;
78  using MovingImagePointer = typename Superclass::MovingImagePointer;
79 
81  using FixedImageType = typename Superclass::FixedImageType;
82  using FixedImagePointer = typename Superclass::FixedImagePointer;
85  using SpacingType = typename FixedImageType::SpacingType;
86 
88  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
89  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
90 
92  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
93 
95  using PixelType = typename Superclass::PixelType;
100 
102  using CoordRepType = double;
107 
110 
114 
119 
122  { m_MovingImageInterpolator = ptr; }
123 
126  { return m_MovingImageInterpolator; }
127 
129  TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) const override
130  { return m_TimeStep; }
131 
134  void * GetGlobalDataPointer() const override
135  {
136  auto * global = new GlobalDataStruct();
137 
138  global->m_SumOfSquaredDifference = 0.0;
139  global->m_NumberOfPixelsProcessed = 0L;
140  global->m_SumOfSquaredChange = 0;
141  return global;
142  }
143 
145  void ReleaseGlobalDataPointer(void *GlobalData) const override;
146 
148  void InitializeIteration() override;
149 
152  PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
153  void *globalData,
154  const FloatOffsetType & offset =
155  FloatOffsetType(0.0) ) override;
156 
160  virtual double GetMetric() const
161  { return m_Metric; }
162 
164  virtual double GetRMSChange() const
165  { return m_RMSChange; }
166 
170  virtual void SetUseMovingImageGradient(bool flag)
171  { m_UseMovingImageGradient = flag; }
172  virtual bool GetUseMovingImageGradient() const
173  { return m_UseMovingImageGradient; }
175 
180  virtual void SetIntensityDifferenceThreshold(double);
181 
182  virtual double GetIntensityDifferenceThreshold() const;
183 
184 protected:
186  ~DemonsRegistrationFunction() override = default;
187  void PrintSelf(std::ostream & os, Indent indent) const override;
188 
191 
198  };
199 
200 private:
202  //SpacingType m_FixedImageSpacing;
203  //PointType m_FixedImageOrigin;
205  double m_Normalizer;
206 
209 
213 
216 
219 
222 
225 
229  mutable double m_Metric;
230  mutable double m_SumOfSquaredDifference;
232  mutable double m_RMSChange;
233  mutable double m_SumOfSquaredChange;
234 
236  mutable std::mutex m_MetricCalculationLock;
237 };
238 } // end namespace itk
239 
240 #ifndef ITK_MANUAL_INSTANTIATION
241 #include "itkDemonsRegistrationFunction.hxx"
242 #endif
243 
244 #endif
void SetMovingImageInterpolator(InterpolatorType *ptr)
typename Superclass::RadiusType RadiusType
typename FixedImageType::IndexType IndexType
typename FixedImageType::SpacingType SpacingType
Light weight base class for most itk classes.
typename Superclass::NeighborhoodType NeighborhoodType
typename InterpolatorType::Pointer InterpolatorPointer
unsigned long SizeValueType
Definition: itkIntTypes.h:83
MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
Calculate the derivative by central differencing.
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
typename Superclass::TimeStepType TimeStepType
typename GradientCalculatorType::Pointer GradientCalculatorPointer
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
typename InterpolatorType::PointType PointType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
TimeStepType ComputeGlobalTimeStep(void *) const override
typename MovingImageType::ConstPointer MovingImagePointer
GradientCalculatorPointer m_FixedImageGradientCalculator
Linearly interpolate an image at specified positions.
Base class for all image interpolaters.
typename FixedImageType::SizeType SizeType
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename Superclass::PixelType PixelType
typename FixedImageType::ConstPointer FixedImagePointer
A templated class holding a n-Dimensional covariant vector.
typename Superclass::FloatOffsetType FloatOffsetType