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 &
50 operator<<(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 CoordRepType = double;
136
139
141
144
148
152
154 void
156 {
157 m_MovingImageInterpolator = ptr;
158 m_MovingImageWarper->SetInterpolator(ptr);
159 }
163 InterpolatorType *
165 {
166 return m_MovingImageInterpolator;
167 }
168
170 TimeStepType
171 ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
172 {
173 return m_TimeStep;
174 }
175
178 void *
179 GetGlobalDataPointer() const override
180 {
181 auto * global = new GlobalDataStruct();
182
183 global->m_SumOfSquaredDifference = 0.0;
184 global->m_NumberOfPixelsProcessed = 0L;
185 global->m_SumOfSquaredChange = 0;
186 return global;
187 }
188
190 void
191 ReleaseGlobalDataPointer(void * gd) const override;
192
194 void
196
200 ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
201
205 virtual double
206 GetMetric() const
207 {
208 return m_Metric;
209 }
210
212 virtual const double &
214 {
215 return m_RMSChange;
216 }
217
222 virtual void
224
225 virtual double
227
231 virtual void
233 {
234 this->m_MaximumUpdateStepLength = sm;
235 }
236
237 virtual double
239 {
240 return this->m_MaximumUpdateStepLength;
241 }
242
244#if !defined(ITK_LEGACY_REMOVE)
246 static constexpr GradientEnum Symmetric = GradientEnum::Symmetric;
247 static constexpr GradientEnum Fixed = GradientEnum::Fixed;
248 static constexpr GradientEnum WarpedMoving = GradientEnum::WarpedMoving;
249 static constexpr GradientEnum MappedMoving = GradientEnum::MappedMoving;
250#endif
251
253 virtual void
255 {
256 m_UseGradientType = gtype;
257 }
258 virtual GradientEnum
260 {
261 return m_UseGradientType;
262 }
265protected:
267 ~ESMDemonsRegistrationFunction() override = default;
268 void
269 PrintSelf(std::ostream & os, Indent indent) const override;
270
273
277 {
281 };
282
283private:
285 PointType m_FixedImageOrigin{};
286 SpacingType m_FixedImageSpacing{};
287 DirectionType m_FixedImageDirection{};
288 double m_Normalizer{};
289
291 GradientCalculatorPointer m_FixedImageGradientCalculator{};
292
294 MovingImageGradientCalculatorPointer m_MappedMovingImageGradientCalculator{};
295
296 GradientEnum m_UseGradientType{};
297
299 InterpolatorPointer m_MovingImageInterpolator{};
300
302 WarperPointer m_MovingImageWarper{};
303
304 MovingImageType * m_MovingImageWarperOutput{};
305
307 TimeStepType m_TimeStep{};
308
310 double m_DenominatorThreshold{};
311
313 double m_IntensityDifferenceThreshold{};
314
316 double m_MaximumUpdateStepLength{};
317
321 mutable double m_Metric{};
322 mutable double m_SumOfSquaredDifference{};
323 mutable SizeValueType m_NumberOfPixelsProcessed{};
324 mutable double m_RMSChange{};
325 mutable double m_SumOfSquaredChange{};
326
328 mutable std::mutex m_MetricCalculationMutex{};
329};
330} // end namespace itk
331
332#ifndef ITK_MANUAL_INSTANTIATION
333# include "itkESMDemonsRegistrationFunction.hxx"
334#endif
335
336#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