ITK  5.1.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  * 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, TMovingImage, TDisplacementField>
56 {
57 public:
58  ITK_DISALLOW_COPY_AND_ASSIGN(DemonsRegistrationFunction);
59 
65 
67  itkNewMacro(Self);
68 
71 
73  using MovingImageType = typename Superclass::MovingImageType;
74  using MovingImagePointer = typename Superclass::MovingImagePointer;
75 
77  using FixedImageType = typename Superclass::FixedImageType;
78  using FixedImagePointer = typename Superclass::FixedImagePointer;
81  using SpacingType = typename FixedImageType::SpacingType;
82 
84  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
85  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
86 
88  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
89 
91  using PixelType = typename Superclass::PixelType;
96 
98  using CoordRepType = double;
103 
106 
110 
114 
116  void
118  {
119  m_MovingImageInterpolator = ptr;
120  }
121 
123  InterpolatorType *
125  {
126  return m_MovingImageInterpolator;
127  }
128 
130  TimeStepType
131  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
132  {
133  return m_TimeStep;
134  }
135 
138  void *
139  GetGlobalDataPointer() const override
140  {
141  auto * global = new GlobalDataStruct();
142 
143  global->m_SumOfSquaredDifference = 0.0;
144  global->m_NumberOfPixelsProcessed = 0L;
145  global->m_SumOfSquaredChange = 0;
146  return global;
147  }
148 
150  void
151  ReleaseGlobalDataPointer(void * GlobalData) const override;
152 
154  void
155  InitializeIteration() override;
156 
159  PixelType
160  ComputeUpdate(const NeighborhoodType & neighborhood,
161  void * globalData,
162  const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
163 
167  virtual double
168  GetMetric() const
169  {
170  return m_Metric;
171  }
172 
174  virtual double
175  GetRMSChange() const
176  {
177  return m_RMSChange;
178  }
179 
183  virtual void
185  {
186  m_UseMovingImageGradient = flag;
187  }
188  virtual bool
190  {
191  return m_UseMovingImageGradient;
192  }
194 
199  virtual void
200  SetIntensityDifferenceThreshold(double);
201 
202  virtual double
203  GetIntensityDifferenceThreshold() const;
204 
205 protected:
207  ~DemonsRegistrationFunction() override = default;
208  void
209  PrintSelf(std::ostream & os, Indent indent) const override;
210 
213 
217  {
221  };
222 
223 private:
225  // SpacingType m_FixedImageSpacing;
226  // PointType m_FixedImageOrigin;
228  double m_Normalizer;
229 
232 
236 
239 
242 
245 
248 
252  mutable double m_Metric;
253  mutable double m_SumOfSquaredDifference;
255  mutable double m_RMSChange;
256  mutable double m_SumOfSquaredChange;
257 
259  mutable std::mutex m_MetricCalculationLock;
260 };
261 } // end namespace itk
262 
263 #ifndef ITK_MANUAL_INSTANTIATION
264 # include "itkDemonsRegistrationFunction.hxx"
265 #endif
266 
267 #endif
itk::DemonsRegistrationFunction::m_IntensityDifferenceThreshold
double m_IntensityDifferenceThreshold
Definition: itkDemonsRegistrationFunction.h:247
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::DemonsRegistrationFunction
Definition: itkDemonsRegistrationFunction.h:54
itk::PDEDeformableRegistrationFunction::MovingImageType
TMovingImage MovingImageType
Definition: itkPDEDeformableRegistrationFunction.h:56
itk::DemonsRegistrationFunction::m_MovingImageGradientCalculator
MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator
Definition: itkDemonsRegistrationFunction.h:234
itk::DemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkDemonsRegistrationFunction.h:81
itk::DemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkDemonsRegistrationFunction.h:219
itk::PDEDeformableRegistrationFunction::MovingImagePointer
typename MovingImageType::ConstPointer MovingImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:57
itkLinearInterpolateImageFunction.h
itk::DemonsRegistrationFunction::m_MetricCalculationLock
std::mutex m_MetricCalculationLock
Definition: itkDemonsRegistrationFunction.h:259
itkPoint.h
itk::DemonsRegistrationFunction::m_DenominatorThreshold
double m_DenominatorThreshold
Definition: itkDemonsRegistrationFunction.h:244
itk::DemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkDemonsRegistrationFunction.h:220
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::DemonsRegistrationFunction::m_ZeroUpdateReturn
PixelType m_ZeroUpdateReturn
Definition: itkDemonsRegistrationFunction.h:227
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::DemonsRegistrationFunction::m_MovingImageInterpolator
InterpolatorPointer m_MovingImageInterpolator
Definition: itkDemonsRegistrationFunction.h:238
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::DemonsRegistrationFunction::m_Metric
double m_Metric
Definition: itkDemonsRegistrationFunction.h:252
itk::DemonsRegistrationFunction::NeighborhoodType
typename Superclass::NeighborhoodType NeighborhoodType
Definition: itkDemonsRegistrationFunction.h:93
itk::DemonsRegistrationFunction::m_FixedImageGradientCalculator
GradientCalculatorPointer m_FixedImageGradientCalculator
Definition: itkDemonsRegistrationFunction.h:231
itk::DemonsRegistrationFunction::m_UseMovingImageGradient
bool m_UseMovingImageGradient
Definition: itkDemonsRegistrationFunction.h:235
itk::DemonsRegistrationFunction::GetUseMovingImageGradient
virtual bool GetUseMovingImageGradient() const
Definition: itkDemonsRegistrationFunction.h:189
itk::DemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkDemonsRegistrationFunction.h:101
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:139
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::DemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkDemonsRegistrationFunction.h:79
itkCentralDifferenceImageFunction.h
itk::PDEDeformableRegistrationFunction::FixedImagePointer
typename FixedImageType::ConstPointer FixedImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:61
itk::DemonsRegistrationFunction::CoordRepType
double CoordRepType
Definition: itkDemonsRegistrationFunction.h:98
itk::DemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkDemonsRegistrationFunction.h:100
itk::DemonsRegistrationFunction::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkDemonsRegistrationFunction.h:256
itk::DemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkDemonsRegistrationFunction.h:168
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:175
itk::DemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkDemonsRegistrationFunction.h:131
itk::DemonsRegistrationFunction::FloatOffsetType
typename Superclass::FloatOffsetType FloatOffsetType
Definition: itkDemonsRegistrationFunction.h:94
itk::DemonsRegistrationFunction::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkDemonsRegistrationFunction.h:95
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:117
itk::PDEDeformableRegistrationFunction::DisplacementFieldTypePointer
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
Definition: itkPDEDeformableRegistrationFunction.h:65
itk::DemonsRegistrationFunction::SetUseMovingImageGradient
virtual void SetUseMovingImageGradient(bool flag)
Definition: itkDemonsRegistrationFunction.h:184
itk::DemonsRegistrationFunction::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkDemonsRegistrationFunction.h:253
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkArray.h:26
itk::DemonsRegistrationFunction::m_RMSChange
double m_RMSChange
Definition: itkDemonsRegistrationFunction.h:255
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::DemonsRegistrationFunction::MovingImageGradientCalculatorPointer
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
Definition: itkDemonsRegistrationFunction.h:113
itk::DemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkDemonsRegistrationFunction.h:218
itk::DemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkDemonsRegistrationFunction.h:124
itk::DemonsRegistrationFunction::m_TimeStep
TimeStepType m_TimeStep
Definition: itkDemonsRegistrationFunction.h:241
itk::FiniteDifferenceFunction< TDisplacementField >
itk::PDEDeformableRegistrationFunction::DisplacementFieldType
TDisplacementField DisplacementFieldType
Definition: itkPDEDeformableRegistrationFunction.h:64
itk::DemonsRegistrationFunction::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkDemonsRegistrationFunction.h:92
itk::DemonsRegistrationFunction::PixelType
typename Superclass::PixelType PixelType
Definition: itkDemonsRegistrationFunction.h:91
itk::DemonsRegistrationFunction::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkDemonsRegistrationFunction.h:254
itk::DemonsRegistrationFunction::GlobalDataStruct
Definition: itkDemonsRegistrationFunction.h:216
itk::DemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkDemonsRegistrationFunction.h:109
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::DemonsRegistrationFunction::m_Normalizer
double m_Normalizer
Definition: itkDemonsRegistrationFunction.h:228
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90