ITK  6.0.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 * 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 itkESMDemonsRegistrationFunction_h
19#define itkESMDemonsRegistrationFunction_h
20
23#include "itkWarpImageFilter.h"
24#include "ITKPDEDeformableRegistrationExport.h"
25#include <mutex>
26
27namespace itk
28{
34{
35public:
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
49extern ITKPDEDeformableRegistration_EXPORT std::ostream &
50operator<<(std::ostream & out, const ESMDemonsRegistrationFunctionEnums::Gradient value);
83template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
84class ITK_TEMPLATE_EXPORT ESMDemonsRegistrationFunction
85 : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
86{
87public:
88 ITK_DISALLOW_COPY_AND_MOVE(ESMDemonsRegistrationFunction);
89
93
96
98 itkNewMacro(Self);
99
101 itkOverrideGetNameOfClassMacro(ESMDemonsRegistrationFunction);
102
104 using typename Superclass::MovingImageType;
105 using typename Superclass::MovingImagePointer;
106 using MovingPixelType = typename MovingImageType::PixelType;
107
109 using typename Superclass::FixedImageType;
110 using typename Superclass::FixedImagePointer;
113 using SpacingType = typename FixedImageType::SpacingType;
115
117 using typename Superclass::DisplacementFieldType;
118 using typename Superclass::DisplacementFieldTypePointer;
119
121 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
122
124 using typename Superclass::PixelType;
125 using typename Superclass::RadiusType;
126 using typename Superclass::NeighborhoodType;
127 using typename Superclass::FloatOffsetType;
128 using typename Superclass::TimeStepType;
129
131 using CoordinateType = double;
132#ifndef ITK_FUTURE_LEGACY_REMOVE
133 using CoordRepType ITK_FUTURE_DEPRECATED(
134 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
135#endif
140
143
145
148
152
156
158 void
160 {
161 m_MovingImageInterpolator = ptr;
162 m_MovingImageWarper->SetInterpolator(ptr);
163 }
167 InterpolatorType *
169 {
170 return m_MovingImageInterpolator;
171 }
172
174 TimeStepType
175 ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
176 {
177 return m_TimeStep;
178 }
179
182 void *
183 GetGlobalDataPointer() const override
184 {
185 auto * global = new GlobalDataStruct();
186
187 global->m_SumOfSquaredDifference = 0.0;
188 global->m_NumberOfPixelsProcessed = 0L;
189 global->m_SumOfSquaredChange = 0;
190 return global;
191 }
192
194 void
195 ReleaseGlobalDataPointer(void * gd) const override;
196
198 void
200
204 ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
205
209 virtual double
210 GetMetric() const
211 {
212 return m_Metric;
213 }
214
216 virtual const double &
218 {
219 return m_RMSChange;
220 }
221
226 virtual void
228
229 virtual double
231
235 virtual void
237 {
238 this->m_MaximumUpdateStepLength = sm;
239 }
240
241 virtual double
243 {
244 return this->m_MaximumUpdateStepLength;
245 }
246
248#if !defined(ITK_LEGACY_REMOVE)
250 static constexpr GradientEnum Symmetric = GradientEnum::Symmetric;
251 static constexpr GradientEnum Fixed = GradientEnum::Fixed;
252 static constexpr GradientEnum WarpedMoving = GradientEnum::WarpedMoving;
253 static constexpr GradientEnum MappedMoving = GradientEnum::MappedMoving;
254#endif
255
257 virtual void
259 {
260 m_UseGradientType = gtype;
261 }
262 virtual GradientEnum
264 {
265 return m_UseGradientType;
266 }
269protected:
271 ~ESMDemonsRegistrationFunction() override = default;
272 void
273 PrintSelf(std::ostream & os, Indent indent) const override;
274
277
281 {
285 };
286
287private:
289 PointType m_FixedImageOrigin{};
290 SpacingType m_FixedImageSpacing{};
291 DirectionType m_FixedImageDirection{};
292 double m_Normalizer{};
293
295 GradientCalculatorPointer m_FixedImageGradientCalculator{};
296
298 MovingImageGradientCalculatorPointer m_MappedMovingImageGradientCalculator{};
299
300 GradientEnum m_UseGradientType{};
301
303 InterpolatorPointer m_MovingImageInterpolator{};
304
306 WarperPointer m_MovingImageWarper{};
307
308 MovingImageType * m_MovingImageWarperOutput{};
309
311 TimeStepType m_TimeStep{};
312
314 double m_DenominatorThreshold{};
315
317 double m_IntensityDifferenceThreshold{};
318
320 double m_MaximumUpdateStepLength{};
321
325 mutable double m_Metric{};
326 mutable double m_SumOfSquaredDifference{};
327 mutable SizeValueType m_NumberOfPixelsProcessed{};
328 mutable double m_RMSChange{};
329 mutable double m_SumOfSquaredChange{};
330
332 mutable std::mutex m_MetricCalculationMutex{};
333};
334} // end namespace itk
335
336#ifndef ITK_MANUAL_INSTANTIATION
337# include "itkESMDemonsRegistrationFunction.hxx"
338#endif
339
340#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.
Contains all enum classes used by ESMDemonsRegistrationFunction class.
Fast implementation of the symmetric demons registration force.
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
~ESMDemonsRegistrationFunction() override=default
typename MovingImageType::PixelType MovingPixelType
typename InterpolatorType::Pointer InterpolatorPointer
typename FixedImageType::DirectionType DirectionType
TimeStepType ComputeGlobalTimeStep(void *) const override
virtual double GetIntensityDifferenceThreshold() const
virtual void SetUseGradientType(GradientEnum gtype)
void ReleaseGlobalDataPointer(void *gd) const override
typename GradientCalculatorType::Pointer GradientCalculatorPointer
typename InterpolatorType::PointType PointType
typename FixedImageType::IndexType IndexType
typename FixedImageType::SpacingType SpacingType
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void SetIntensityDifferenceThreshold(double)
PixelType ComputeUpdate(const NeighborhoodType &it, void *gd, const FloatOffsetType &offset=FloatOffsetType(0.0)) override
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
Warps an image using an input displacement field.
SmartPointer< Self > Pointer
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, typename AnatomicalOrientation::CoordinateEnum value)
unsigned long SizeValueType
Definition: itkIntTypes.h:86