ITK  6.0.0
Insight Toolkit
itkDemonsRegistrationFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright NumFOCUS
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  * https://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, TMovingImage, TDisplacementField>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_MOVE(DemonsRegistrationFunction);
59 
65 
67  itkNewMacro(Self);
68 
70  itkOverrideGetNameOfClassMacro(DemonsRegistrationFunction);
71 
73  using typename Superclass::MovingImageType;
74  using typename Superclass::MovingImagePointer;
75 
77  using typename Superclass::FixedImageType;
78  using typename Superclass::FixedImagePointer;
81  using SpacingType = typename FixedImageType::SpacingType;
82 
84  using typename Superclass::DisplacementFieldType;
85  using typename Superclass::DisplacementFieldTypePointer;
86 
88  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
89 
91  using typename Superclass::PixelType;
92  using typename Superclass::RadiusType;
93  using typename Superclass::NeighborhoodType;
94  using typename Superclass::FloatOffsetType;
95  using typename Superclass::TimeStepType;
96 
98  using CoordinateType = double;
99 #ifndef ITK_FUTURE_LEGACY_REMOVE
100  using CoordRepType ITK_FUTURE_DEPRECATED(
101  "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
102 #endif
107 
110 
114 
118 
120  void
122  {
123  m_MovingImageInterpolator = ptr;
124  }
125 
127  InterpolatorType *
129  {
130  return m_MovingImageInterpolator;
131  }
132 
134  TimeStepType
135  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
136  {
137  return m_TimeStep;
138  }
139 
142  void *
143  GetGlobalDataPointer() const override
144  {
145  auto * global = new GlobalDataStruct();
146 
147  global->m_SumOfSquaredDifference = 0.0;
148  global->m_NumberOfPixelsProcessed = 0L;
149  global->m_SumOfSquaredChange = 0;
150  return global;
151  }
152 
157  void
158  ReleaseGlobalDataPointer(void * gd) const override;
159 
161  void
162  InitializeIteration() override;
163 
168  PixelType
169  ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
170 
174  virtual double
175  GetMetric() const
176  {
177  return m_Metric;
178  }
179 
181  virtual double
182  GetRMSChange() const
183  {
184  return m_RMSChange;
185  }
186 
190  virtual void
192  {
193  m_UseMovingImageGradient = flag;
194  }
195  virtual bool
197  {
198  return m_UseMovingImageGradient;
199  }
206  virtual void
207  SetIntensityDifferenceThreshold(double);
208 
209  virtual double
210  GetIntensityDifferenceThreshold() const;
211 
212 protected:
214  ~DemonsRegistrationFunction() override = default;
215  void
216  PrintSelf(std::ostream & os, Indent indent) const override;
217 
220 
224  {
228  };
229 
230 private:
232  // SpacingType m_FixedImageSpacing;
233  // PointType m_FixedImageOrigin;
234  PixelType m_ZeroUpdateReturn{};
235  double m_Normalizer{};
236 
238  GradientCalculatorPointer m_FixedImageGradientCalculator{};
239 
241  MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator{};
242  bool m_UseMovingImageGradient{};
243 
245  InterpolatorPointer m_MovingImageInterpolator{};
246 
248  TimeStepType m_TimeStep{};
249 
251  double m_DenominatorThreshold{};
252 
254  double m_IntensityDifferenceThreshold{};
255 
259  mutable double m_Metric{};
260  mutable double m_SumOfSquaredDifference{};
261  mutable SizeValueType m_NumberOfPixelsProcessed{};
262  mutable double m_RMSChange{};
263  mutable double m_SumOfSquaredChange{};
264 
266  mutable std::mutex m_MetricCalculationMutex{};
267 };
268 } // end namespace itk
269 
270 #ifndef ITK_MANUAL_INSTANTIATION
271 # include "itkDemonsRegistrationFunction.hxx"
272 #endif
273 
274 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::DemonsRegistrationFunction
Definition: itkDemonsRegistrationFunction.h:54
itk::DemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkDemonsRegistrationFunction.h:81
itk::DemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkDemonsRegistrationFunction.h:226
itkLinearInterpolateImageFunction.h
itkPoint.h
itk::DemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkDemonsRegistrationFunction.h:227
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkPDEDeformableRegistrationFunction.h
itk::CentralDifferenceImageFunction
Calculate the derivative by central differencing.
Definition: itkCentralDifferenceImageFunction.h:76
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DemonsRegistrationFunction::GetUseMovingImageGradient
virtual bool GetUseMovingImageGradient() const
Definition: itkDemonsRegistrationFunction.h:196
itk::DemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkDemonsRegistrationFunction.h:105
itk::DemonsRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkDemonsRegistrationFunction.h:80
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::DemonsRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkDemonsRegistrationFunction.h:143
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:51
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::DemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkDemonsRegistrationFunction.h:79
itkCentralDifferenceImageFunction.h
itk::DemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkDemonsRegistrationFunction.h:104
itk::DemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkDemonsRegistrationFunction.h:175
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::DemonsRegistrationFunction::GetRMSChange
virtual double GetRMSChange() const
Definition: itkDemonsRegistrationFunction.h:182
itk::DemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkDemonsRegistrationFunction.h:135
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::DemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkDemonsRegistrationFunction.h:121
itk::DemonsRegistrationFunction::SetUseMovingImageGradient
virtual void SetUseMovingImageGradient(bool flag)
Definition: itkDemonsRegistrationFunction.h:191
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::DemonsRegistrationFunction::MovingImageGradientCalculatorPointer
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
Definition: itkDemonsRegistrationFunction.h:117
itk::DemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkDemonsRegistrationFunction.h:225
itk::DemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkDemonsRegistrationFunction.h:128
itk::FiniteDifferenceFunction< TDisplacementField >
itk::DemonsRegistrationFunction::CoordinateType
double CoordinateType
Definition: itkDemonsRegistrationFunction.h:98
itk::DemonsRegistrationFunction::GlobalDataStruct
Definition: itkDemonsRegistrationFunction.h:223
itk::DemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkDemonsRegistrationFunction.h:113
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90