ITK  5.2.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  * 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 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_ASSIGN(SymmetricForcesDemonsRegistrationFunction);
67 
73 
75  itkNewMacro(Self);
76 
79 
81  using MovingImageType = typename Superclass::MovingImageType;
82  using MovingImagePointer = typename Superclass::MovingImagePointer;
83 
85  using FixedImageType = typename Superclass::FixedImageType;
86  using FixedImagePointer = typename Superclass::FixedImagePointer;
89  using SpacingType = typename FixedImageType::SpacingType;
90 
92  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
93  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
94 
96  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
97 
99  using PixelType = typename Superclass::PixelType;
103  using TimeStepType = typename Superclass::TimeStepType;
104 
106  using CoordRepType = double;
111 
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 
154  void
155  ReleaseGlobalDataPointer(void * GlobalData) const override;
156 
158  void
159  InitializeIteration() override;
160 
163  PixelType
164  ComputeUpdate(const NeighborhoodType & neighborhood,
165  void * globalData,
166  const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
167 
171  virtual double
172  GetMetric() const
173  {
174  return m_Metric;
175  }
176 
178  virtual const double &
179  GetRMSChange() const
180  {
181  return m_RMSChange;
182  }
183 
188  virtual void
189  SetIntensityDifferenceThreshold(double);
190 
191  virtual double
192  GetIntensityDifferenceThreshold() const;
193 
194 protected:
196  ~SymmetricForcesDemonsRegistrationFunction() override = default;
197  void
198  PrintSelf(std::ostream & os, Indent indent) const override;
199 
202 
206  {
210  };
211 
212 private:
216  double m_Normalizer;
217 
220 
223 
226 
229 
232 
236  mutable double m_Metric;
237  mutable double m_SumOfSquaredDifference;
239  mutable double m_RMSChange;
240  mutable double m_SumOfSquaredChange;
241 
243  mutable std::mutex m_MetricCalculationLock;
244 };
245 } // end namespace itk
246 
247 #ifndef ITK_MANUAL_INSTANTIATION
248 # include "itkSymmetricForcesDemonsRegistrationFunction.hxx"
249 #endif
250 
251 #endif
itk::SymmetricForcesDemonsRegistrationFunction::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:238
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::SymmetricForcesDemonsRegistrationFunction::m_Metric
double m_Metric
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:236
itk::SymmetricForcesDemonsRegistrationFunction::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:237
itk::PDEDeformableRegistrationFunction::MovingImageType
TMovingImage MovingImageType
Definition: itkPDEDeformableRegistrationFunction.h:56
itk::SymmetricForcesDemonsRegistrationFunction::m_MetricCalculationLock
std::mutex m_MetricCalculationLock
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:243
itk::PDEDeformableRegistrationFunction::MovingImagePointer
typename MovingImageType::ConstPointer MovingImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:57
itkLinearInterpolateImageFunction.h
itk::SymmetricForcesDemonsRegistrationFunction::FloatOffsetType
typename Superclass::FloatOffsetType FloatOffsetType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:102
itkPoint.h
itk::SymmetricForcesDemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:128
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:207
itk::SymmetricForcesDemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:121
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkPDEDeformableRegistrationFunction.h
itk::SymmetricForcesDemonsRegistrationFunction::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:100
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:109
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SymmetricForcesDemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:117
itk::SymmetricForcesDemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:87
itk::SmartPointer< Self >
itk::SymmetricForcesDemonsRegistrationFunction::m_MovingImageInterpolator
InterpolatorPointer m_MovingImageInterpolator
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:222
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::SymmetricForcesDemonsRegistrationFunction
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:62
itk::SymmetricForcesDemonsRegistrationFunction::NeighborhoodType
typename Superclass::NeighborhoodType NeighborhoodType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:101
itk::SymmetricForcesDemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:89
itk::SymmetricForcesDemonsRegistrationFunction::m_IntensityDifferenceThreshold
double m_IntensityDifferenceThreshold
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:231
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:50
itk::SymmetricForcesDemonsRegistrationFunction::m_DenominatorThreshold
double m_DenominatorThreshold
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:228
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkCentralDifferenceImageFunction.h
itk::PDEDeformableRegistrationFunction::FixedImagePointer
typename FixedImageType::ConstPointer FixedImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:61
itk::SymmetricForcesDemonsRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:143
itk::SymmetricForcesDemonsRegistrationFunction::m_RMSChange
double m_RMSChange
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:239
itk::SymmetricForcesDemonsRegistrationFunction::PixelType
typename Superclass::PixelType PixelType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:99
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:209
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:208
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::SymmetricForcesDemonsRegistrationFunction::GetRMSChange
virtual const double & GetRMSChange() const
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:179
itk::SymmetricForcesDemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:172
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::PDEDeformableRegistrationFunction::DisplacementFieldTypePointer
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
Definition: itkPDEDeformableRegistrationFunction.h:65
itk::SymmetricForcesDemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:135
itk::SymmetricForcesDemonsRegistrationFunction::m_FixedImageOrigin
PointType m_FixedImageOrigin
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:215
itk::SymmetricForcesDemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:108
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::SymmetricForcesDemonsRegistrationFunction::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:103
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:50
itk::PDEDeformableRegistrationFunction::FixedImageType
TFixedImage FixedImageType
Definition: itkPDEDeformableRegistrationFunction.h:60
itk::SymmetricForcesDemonsRegistrationFunction::CoordRepType
double CoordRepType
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:106
itk::FiniteDifferenceFunction< TDisplacementField >
itk::SymmetricForcesDemonsRegistrationFunction::m_FixedImageGradientCalculator
GradientCalculatorPointer m_FixedImageGradientCalculator
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:219
itk::SymmetricForcesDemonsRegistrationFunction::GlobalDataStruct
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:205
itk::SymmetricForcesDemonsRegistrationFunction::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:240
itk::PDEDeformableRegistrationFunction::DisplacementFieldType
TDisplacementField DisplacementFieldType
Definition: itkPDEDeformableRegistrationFunction.h:64
itk::SymmetricForcesDemonsRegistrationFunction::m_Normalizer
double m_Normalizer
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:216
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:83
itk::SymmetricForcesDemonsRegistrationFunction::m_FixedImageSpacing
SpacingType m_FixedImageSpacing
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:214
itk::SymmetricForcesDemonsRegistrationFunction::m_TimeStep
TimeStepType m_TimeStep
Definition: itkSymmetricForcesDemonsRegistrationFunction.h:225