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
27namespace itk
28{
53template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
54class ITK_TEMPLATE_EXPORT DemonsRegistrationFunction
55 : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
56{
57public:
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 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
153 void
154 ReleaseGlobalDataPointer(void * gd) const override;
155
157 void
159
165 ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
166
170 virtual double
171 GetMetric() const
172 {
173 return m_Metric;
174 }
175
177 virtual double
179 {
180 return m_RMSChange;
181 }
182
186 virtual void
188 {
189 m_UseMovingImageGradient = flag;
190 }
191 virtual bool
193 {
194 return m_UseMovingImageGradient;
195 }
202 virtual void
204
205 virtual double
207
208protected:
210 ~DemonsRegistrationFunction() override = default;
211 void
212 PrintSelf(std::ostream & os, Indent indent) const override;
213
216
220 {
224 };
225
226private:
228 // SpacingType m_FixedImageSpacing;
229 // PointType m_FixedImageOrigin;
230 PixelType m_ZeroUpdateReturn{};
231 double m_Normalizer{};
232
234 GradientCalculatorPointer m_FixedImageGradientCalculator{};
235
237 MovingImageGradientCalculatorPointer m_MovingImageGradientCalculator{};
238 bool m_UseMovingImageGradient{};
239
241 InterpolatorPointer m_MovingImageInterpolator{};
242
244 TimeStepType m_TimeStep{};
245
247 double m_DenominatorThreshold{};
248
250 double m_IntensityDifferenceThreshold{};
251
255 mutable double m_Metric{};
256 mutable double m_SumOfSquaredDifference{};
257 mutable SizeValueType m_NumberOfPixelsProcessed{};
258 mutable double m_RMSChange{};
259 mutable double m_SumOfSquaredChange{};
260
262 mutable std::mutex m_MetricCalculationMutex{};
263};
264} // end namespace itk
265
266#ifndef ITK_MANUAL_INSTANTIATION
267# include "itkDemonsRegistrationFunction.hxx"
268#endif
269
270#endif
Calculate the derivative by central differencing.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
A templated class holding a n-Dimensional covariant vector.
typename GradientCalculatorType::Pointer GradientCalculatorPointer
~DemonsRegistrationFunction() override=default
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
void ReleaseGlobalDataPointer(void *gd) const override
void InitializeIteration() override
typename FixedImageType::SizeType SizeType
PixelType ComputeUpdate(const NeighborhoodType &it, void *gd, const FloatOffsetType &offset=FloatOffsetType(0.0)) override
typename InterpolatorType::PointType PointType
typename InterpolatorType::Pointer InterpolatorPointer
void PrintSelf(std::ostream &os, Indent indent) const override
TimeStepType ComputeGlobalTimeStep(void *) const override
typename FixedImageType::SpacingType SpacingType
void SetMovingImageInterpolator(InterpolatorType *ptr)
virtual double GetIntensityDifferenceThreshold() const
typename FixedImageType::IndexType IndexType
virtual void SetIntensityDifferenceThreshold(double)
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Control indentation during Print() invocation.
Definition: itkIndent.h:50
Base class for all image interpolators.
Light weight base class for most itk classes.
Linearly interpolate an image at specified positions.
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:63
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition: itkIntTypes.h:86