ITK  5.2.0
Insight Toolkit
itkESMDemonsRegistrationFunction.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  * 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 itkESMDemonsRegistrationFunction_h
19 #define itkESMDemonsRegistrationFunction_h
20 
23 #include "itkWarpImageFilter.h"
24 #include "ITKPDEDeformableRegistrationExport.h"
25 #include <mutex>
26 
27 namespace itk
28 {
34 {
35 public:
40  enum class Gradient : uint8_t
41  {
42  Symmetric = 0,
43  Fixed = 1,
44  WarpedMoving = 2,
45  MappedMoving = 3
46  };
47 };
48 // Define how to print enumeration
49 extern ITKPDEDeformableRegistration_EXPORT std::ostream &
50  operator<<(std::ostream & out, const ESMDemonsRegistrationFunctionEnums::Gradient value);
83 template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
84 class ITK_TEMPLATE_EXPORT ESMDemonsRegistrationFunction
85  : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
86 {
87 public:
88  ITK_DISALLOW_COPY_AND_MOVE(ESMDemonsRegistrationFunction);
89 
93 
96 
98  itkNewMacro(Self);
99 
102 
104  using MovingImageType = typename Superclass::MovingImageType;
105  using MovingImagePointer = typename Superclass::MovingImagePointer;
106  using MovingPixelType = typename MovingImageType::PixelType;
107 
109  using FixedImageType = typename Superclass::FixedImageType;
110  using FixedImagePointer = typename Superclass::FixedImagePointer;
113  using SpacingType = typename FixedImageType::SpacingType;
115 
117  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
118  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
119 
121  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
122 
129 
131  using CoordRepType = double;
136 
139 
141 
144 
148 
152 
154  void
156  {
157  m_MovingImageInterpolator = ptr;
158  m_MovingImageWarper->SetInterpolator(ptr);
159  }
161 
163  InterpolatorType *
165  {
166  return m_MovingImageInterpolator;
167  }
168 
170  TimeStepType
171  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
172  {
173  return m_TimeStep;
174  }
175 
178  void *
179  GetGlobalDataPointer() const override
180  {
181  auto * global = new GlobalDataStruct();
182 
183  global->m_SumOfSquaredDifference = 0.0;
184  global->m_NumberOfPixelsProcessed = 0L;
185  global->m_SumOfSquaredChange = 0;
186  return global;
187  }
188 
190  void
191  ReleaseGlobalDataPointer(void * gd) const override;
192 
194  void
195  InitializeIteration() override;
196 
199  PixelType
200  ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
201 
205  virtual double
206  GetMetric() const
207  {
208  return m_Metric;
209  }
210 
212  virtual const double &
213  GetRMSChange() const
214  {
215  return m_RMSChange;
216  }
217 
222  virtual void
223  SetIntensityDifferenceThreshold(double);
224 
225  virtual double
226  GetIntensityDifferenceThreshold() const;
227 
231  virtual void
233  {
234  this->m_MaximumUpdateStepLength = sm;
235  }
236 
237  virtual double
239  {
240  return this->m_MaximumUpdateStepLength;
241  }
242 
244 #if !defined(ITK_LEGACY_REMOVE)
245 
246  static constexpr GradientEnum Symmetric = GradientEnum::Symmetric;
247  static constexpr GradientEnum Fixed = GradientEnum::Fixed;
248  static constexpr GradientEnum WarpedMoving = GradientEnum::WarpedMoving;
249  static constexpr GradientEnum MappedMoving = GradientEnum::MappedMoving;
250 #endif
251 
253  virtual void
255  {
256  m_UseGradientType = gtype;
257  }
258  virtual GradientEnum
260  {
261  return m_UseGradientType;
262  }
264 
265 protected:
267  ~ESMDemonsRegistrationFunction() override = default;
268  void
269  PrintSelf(std::ostream & os, Indent indent) const override;
270 
273 
277  {
281  };
282 
283 private:
288  double m_Normalizer;
289 
292 
295 
297 
300 
303 
305 
308 
311 
314 
317 
321  mutable double m_Metric;
322  mutable double m_SumOfSquaredDifference;
324  mutable double m_RMSChange;
325  mutable double m_SumOfSquaredChange;
326 
328  mutable std::mutex m_MetricCalculationLock;
329 };
330 } // end namespace itk
331 
332 #ifndef ITK_MANUAL_INSTANTIATION
333 # include "itkESMDemonsRegistrationFunction.hxx"
334 #endif
335 
336 #endif
itk::ESMDemonsRegistrationFunction::m_FixedImageDirection
DirectionType m_FixedImageDirection
Definition: itkESMDemonsRegistrationFunction.h:287
itk::ESMDemonsRegistrationFunction::m_IntensityDifferenceThreshold
double m_IntensityDifferenceThreshold
Definition: itkESMDemonsRegistrationFunction.h:313
itk::ESMDemonsRegistrationFunction::m_DenominatorThreshold
double m_DenominatorThreshold
Definition: itkESMDemonsRegistrationFunction.h:310
itk::ESMDemonsRegistrationFunction::m_TimeStep
TimeStepType m_TimeStep
Definition: itkESMDemonsRegistrationFunction.h:307
itk::ESMDemonsRegistrationFunction::m_MovingImageWarperOutput
MovingImageType * m_MovingImageWarperOutput
Definition: itkESMDemonsRegistrationFunction.h:304
itk::uint8_t
::uint8_t uint8_t
Definition: itkIntTypes.h:29
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::ESMDemonsRegistrationFunctionEnums::Gradient::Symmetric
itk::ESMDemonsRegistrationFunction::MovingPixelType
typename MovingImageType::PixelType MovingPixelType
Definition: itkESMDemonsRegistrationFunction.h:106
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::ESMDemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkESMDemonsRegistrationFunction.h:111
itk::ESMDemonsRegistrationFunction::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkESMDemonsRegistrationFunction.h:322
itk::ESMDemonsRegistrationFunction::GetMaximumUpdateStepLength
virtual double GetMaximumUpdateStepLength() const
Definition: itkESMDemonsRegistrationFunction.h:238
itk::ESMDemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkESMDemonsRegistrationFunction.h:147
itk::ESMDemonsRegistrationFunction::GetRMSChange
virtual const double & GetRMSChange() const
Definition: itkESMDemonsRegistrationFunction.h:213
itk::ESMDemonsRegistrationFunction::m_MovingImageWarper
WarperPointer m_MovingImageWarper
Definition: itkESMDemonsRegistrationFunction.h:302
itk::operator<<
std::ostream & operator<<(std::ostream &os, const Array< TValue > &arr)
Definition: itkArray.h:218
itk::PDEDeformableRegistrationFunction::MovingImagePointer
typename MovingImageType::ConstPointer MovingImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:57
itk::ESMDemonsRegistrationFunction::GlobalDataStruct
Definition: itkESMDemonsRegistrationFunction.h:276
itk::ESMDemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkESMDemonsRegistrationFunction.h:155
GradientEnum
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkPDEDeformableRegistrationFunction.h
itk::ESMDemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkESMDemonsRegistrationFunction.h:171
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::ESMDemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkESMDemonsRegistrationFunction.h:279
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ESMDemonsRegistrationFunction::m_MappedMovingImageGradientCalculator
MovingImageGradientCalculatorPointer m_MappedMovingImageGradientCalculator
Definition: itkESMDemonsRegistrationFunction.h:294
itkWarpImageFilter.h
itk::ESMDemonsRegistrationFunction::PixelType
typename Superclass::PixelType PixelType
Definition: itkESMDemonsRegistrationFunction.h:124
itk::ESMDemonsRegistrationFunction::m_MaximumUpdateStepLength
double m_MaximumUpdateStepLength
Definition: itkESMDemonsRegistrationFunction.h:316
itk::ESMDemonsRegistrationFunction::MovingImageGradientCalculatorPointer
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
Definition: itkESMDemonsRegistrationFunction.h:151
itk::ESMDemonsRegistrationFunction::WarperPointer
typename WarperType::Pointer WarperPointer
Definition: itkESMDemonsRegistrationFunction.h:140
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ESMDemonsRegistrationFunction::SetUseGradientType
virtual void SetUseGradientType(GradientEnum gtype)
Definition: itkESMDemonsRegistrationFunction.h:254
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:50
itk::ESMDemonsRegistrationFunction::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkESMDemonsRegistrationFunction.h:325
itk::ESMDemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkESMDemonsRegistrationFunction.h:133
itk::ESMDemonsRegistrationFunctionEnums
Contains all enum classes used by ESMDemonsRegistrationFunction class.
Definition: itkESMDemonsRegistrationFunction.h:33
itk::ESMDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkESMDemonsRegistrationFunction.h:280
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkCentralDifferenceImageFunction.h
itk::ESMDemonsRegistrationFunctionEnums::Gradient::Fixed
itk::ESMDemonsRegistrationFunction::m_Metric
double m_Metric
Definition: itkESMDemonsRegistrationFunction.h:321
itk::PDEDeformableRegistrationFunction::FixedImagePointer
typename FixedImageType::ConstPointer FixedImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:61
itk::ESMDemonsRegistrationFunction::DirectionType
typename FixedImageType::DirectionType DirectionType
Definition: itkESMDemonsRegistrationFunction.h:114
itk::ESMDemonsRegistrationFunction::MovingImageType
typename Superclass::MovingImageType MovingImageType
Definition: itkESMDemonsRegistrationFunction.h:104
itk::ESMDemonsRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkESMDemonsRegistrationFunction.h:112
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::ESMDemonsRegistrationFunction::m_FixedImageGradientCalculator
GradientCalculatorPointer m_FixedImageGradientCalculator
Definition: itkESMDemonsRegistrationFunction.h:291
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::ESMDemonsRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkESMDemonsRegistrationFunction.h:179
itk::ESMDemonsRegistrationFunction::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkESMDemonsRegistrationFunction.h:323
itk::ESMDemonsRegistrationFunction
Fast implementation of the symmetric demons registration force.
Definition: itkESMDemonsRegistrationFunction.h:84
itk::ESMDemonsRegistrationFunction::FloatOffsetType
typename Superclass::FloatOffsetType FloatOffsetType
Definition: itkESMDemonsRegistrationFunction.h:127
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::ESMDemonsRegistrationFunction::m_MovingImageInterpolator
InterpolatorPointer m_MovingImageInterpolator
Definition: itkESMDemonsRegistrationFunction.h:299
itk::PDEDeformableRegistrationFunction::DisplacementFieldTypePointer
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
Definition: itkPDEDeformableRegistrationFunction.h:65
itk::ESMDemonsRegistrationFunctionEnums::Gradient
Gradient
Definition: itkESMDemonsRegistrationFunction.h:40
itk::ESMDemonsRegistrationFunction::NeighborhoodType
typename Superclass::NeighborhoodType NeighborhoodType
Definition: itkESMDemonsRegistrationFunction.h:126
itk::WarpImageFilter
Warps an image using an input displacement field.
Definition: itkWarpImageFilter.h:85
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::ESMDemonsRegistrationFunction::CoordRepType
double CoordRepType
Definition: itkESMDemonsRegistrationFunction.h:131
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::PDEDeformableRegistrationFunction::FixedImageType
TFixedImage FixedImageType
Definition: itkPDEDeformableRegistrationFunction.h:60
itk::ESMDemonsRegistrationFunctionEnums::Gradient::MappedMoving
itk::ESMDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkESMDemonsRegistrationFunction.h:278
itk::FiniteDifferenceFunction< TDisplacementField >
itk::ESMDemonsRegistrationFunctionEnums::Gradient::WarpedMoving
itk::ESMDemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkESMDemonsRegistrationFunction.h:164
itk::ESMDemonsRegistrationFunction::SetMaximumUpdateStepLength
virtual void SetMaximumUpdateStepLength(double sm)
Definition: itkESMDemonsRegistrationFunction.h:232
itk::ESMDemonsRegistrationFunction::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkESMDemonsRegistrationFunction.h:128
itk::ESMDemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkESMDemonsRegistrationFunction.h:134
itk::PDEDeformableRegistrationFunction::DisplacementFieldType
TDisplacementField DisplacementFieldType
Definition: itkPDEDeformableRegistrationFunction.h:64
itk::ESMDemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkESMDemonsRegistrationFunction.h:206
itk::ESMDemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkESMDemonsRegistrationFunction.h:113
itk::ESMDemonsRegistrationFunction::m_UseGradientType
GradientEnum m_UseGradientType
Definition: itkESMDemonsRegistrationFunction.h:296
itk::ESMDemonsRegistrationFunction::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkESMDemonsRegistrationFunction.h:125
itk::ESMDemonsRegistrationFunction::m_RMSChange
double m_RMSChange
Definition: itkESMDemonsRegistrationFunction.h:324
itk::ESMDemonsRegistrationFunction::m_Normalizer
double m_Normalizer
Definition: itkESMDemonsRegistrationFunction.h:288
itk::ESMDemonsRegistrationFunction::m_MetricCalculationLock
std::mutex m_MetricCalculationLock
Definition: itkESMDemonsRegistrationFunction.h:328
itk::ESMDemonsRegistrationFunction::m_FixedImageOrigin
PointType m_FixedImageOrigin
Definition: itkESMDemonsRegistrationFunction.h:285
itk::ESMDemonsRegistrationFunction::GetUseGradientType
virtual GradientEnum GetUseGradientType() const
Definition: itkESMDemonsRegistrationFunction.h:259
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::ESMDemonsRegistrationFunction::m_FixedImageSpacing
SpacingType m_FixedImageSpacing
Definition: itkESMDemonsRegistrationFunction.h:286
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90