ITK  6.0.0
Insight Toolkit
itkSymmetricForcesDemonsRegistrationFunction.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 itkSymmetricForcesDemonsRegistrationFunction_h
19 #define itkSymmetricForcesDemonsRegistrationFunction_h
20 
22 #include "itkPoint.h"
25 #include <mutex>
26 
27 namespace itk
28 {
61 template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
63  : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
64 {
65 public:
66  ITK_DISALLOW_COPY_AND_MOVE(SymmetricForcesDemonsRegistrationFunction);
67 
73 
75  itkNewMacro(Self);
76 
78  itkOverrideGetNameOfClassMacro(SymmetricForcesDemonsRegistrationFunction);
79 
81  using typename Superclass::MovingImageType;
82  using typename Superclass::MovingImagePointer;
83 
85  using typename Superclass::FixedImageType;
86  using typename Superclass::FixedImagePointer;
89  using SpacingType = typename FixedImageType::SpacingType;
90 
92  using typename Superclass::DisplacementFieldType;
93  using typename Superclass::DisplacementFieldTypePointer;
94 
96  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
97 
99  using typename Superclass::PixelType;
100  using typename Superclass::RadiusType;
101  using typename Superclass::NeighborhoodType;
102  using typename Superclass::FloatOffsetType;
103  using typename Superclass::TimeStepType;
104 
106  using CoordinateType = double;
107 #ifndef ITK_FUTURE_LEGACY_REMOVE
108  using CoordRepType ITK_FUTURE_DEPRECATED(
109  "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
110 #endif
115 
118 
122 
124  void
126  {
127  m_MovingImageInterpolator = ptr;
128  }
129 
131  InterpolatorType *
133  {
134  return m_MovingImageInterpolator;
135  }
136 
138  TimeStepType
139  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
140  {
141  return m_TimeStep;
142  }
143 
146  void *
147  GetGlobalDataPointer() const override
148  {
149  auto * global = new GlobalDataStruct();
150 
151  global->m_SumOfSquaredDifference = 0.0;
152  global->m_NumberOfPixelsProcessed = 0L;
153  global->m_SumOfSquaredChange = 0;
154  return global;
155  }
156 
161  void
162  ReleaseGlobalDataPointer(void * gd) const override;
163 
165  void
166  InitializeIteration() override;
167 
172  PixelType
173  ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
174 
178  virtual double
179  GetMetric() const
180  {
181  return m_Metric;
182  }
183 
185  virtual const double &
186  GetRMSChange() const
187  {
188  return m_RMSChange;
189  }
190 
195  virtual void
196  SetIntensityDifferenceThreshold(double);
197 
198  virtual double
199  GetIntensityDifferenceThreshold() const;
200 
201 protected:
203  ~SymmetricForcesDemonsRegistrationFunction() override = default;
204  void
205  PrintSelf(std::ostream & os, Indent indent) const override;
206 
209 
213  {
217  };
218 
219 private:
221  SpacingType m_FixedImageSpacing{};
222  PointType m_FixedImageOrigin{};
223  double m_Normalizer{};
224 
226  GradientCalculatorPointer m_FixedImageGradientCalculator{};
227 
229  InterpolatorPointer m_MovingImageInterpolator{};
230 
232  TimeStepType m_TimeStep{};
233 
235  double m_DenominatorThreshold{};
236 
238  double m_IntensityDifferenceThreshold{};
239 
243  mutable double m_Metric{};
244  mutable double m_SumOfSquaredDifference{};
245  mutable SizeValueType m_NumberOfPixelsProcessed{};
246  mutable double m_RMSChange{};
247  mutable double m_SumOfSquaredChange{};
248 
250  mutable std::mutex m_MetricCalculationMutex{};
251 };
252 } // end namespace itk
253 
254 #ifndef ITK_MANUAL_INSTANTIATION
255 # include "itkSymmetricForcesDemonsRegistrationFunction.hxx"
256 #endif
257 
258 #endif
itk::SymmetricForcesDemonsRegistrationFunction::CoordinateType
double CoordinateType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:106
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itkLinearInterpolateImageFunction.h
itkPoint.h
itk::SymmetricForcesDemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:132
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:214
itk::SymmetricForcesDemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:125
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::SymmetricForcesDemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:113
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SymmetricForcesDemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:121
itk::SymmetricForcesDemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:87
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SymmetricForcesDemonsRegistrationFunction
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:62
itk::SymmetricForcesDemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:89
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
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
itkCentralDifferenceImageFunction.h
itk::SymmetricForcesDemonsRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:147
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:216
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:215
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::SymmetricForcesDemonsRegistrationFunction::GetRMSChange
virtual const double & GetRMSChange() const
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:186
itk::SymmetricForcesDemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:179
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::SymmetricForcesDemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:139
itk::SymmetricForcesDemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:112
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::FiniteDifferenceFunction< TDisplacementField >
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:212
itk::SymmetricForcesDemonsRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:88
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