ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
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 {
43 Fixed = 1,
46 };
47};
48// Define how to print enumeration
49extern ITKPDEDeformableRegistration_EXPORT std::ostream &
50operator<<(std::ostream & out, const ESMDemonsRegistrationFunctionEnums::Gradient value);
85template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
86class ITK_TEMPLATE_EXPORT ESMDemonsRegistrationFunction
87 : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
88{
89public:
90 ITK_DISALLOW_COPY_AND_MOVE(ESMDemonsRegistrationFunction);
91
95
98
100 itkNewMacro(Self);
101
103 itkOverrideGetNameOfClassMacro(ESMDemonsRegistrationFunction);
104
106 using typename Superclass::MovingImageType;
107 using typename Superclass::MovingImagePointer;
108 using MovingPixelType = typename MovingImageType::PixelType;
109
111 using typename Superclass::FixedImageType;
112 using typename Superclass::FixedImagePointer;
113 using IndexType = typename FixedImageType::IndexType;
114 using SizeType = typename FixedImageType::SizeType;
115 using SpacingType = typename FixedImageType::SpacingType;
116 using DirectionType = typename FixedImageType::DirectionType;
117
121
123 static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
124
126 using typename Superclass::PixelType;
127 using typename Superclass::RadiusType;
128 using typename Superclass::NeighborhoodType;
129 using typename Superclass::FloatOffsetType;
130 using typename Superclass::TimeStepType;
131
133 using CoordinateType = double;
134#ifndef ITK_FUTURE_LEGACY_REMOVE
135 using CoordRepType ITK_FUTURE_DEPRECATED(
136 "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
137#endif
142
145
147
150
154
158
160 void
162 {
164 m_MovingImageWarper->SetInterpolator(ptr);
165 }
166
168 InterpolatorType *
173
175 TimeStepType
176 ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
177 {
178 return m_TimeStep;
179 }
180
183 void *
184 GetGlobalDataPointer() const override
185 {
186 auto * global = new GlobalDataStruct();
187
188 global->m_SumOfSquaredDifference = 0.0;
189 global->m_NumberOfPixelsProcessed = 0L;
190 global->m_SumOfSquaredChange = 0;
191 return global;
192 }
193
195 void
196 ReleaseGlobalDataPointer(void * gd) const override;
197
199 void
201
205 ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
206
210 virtual double
211 GetMetric() const
212 {
213 return m_Metric;
214 }
215
217 virtual const double &
219 {
220 return m_RMSChange;
221 }
222
227 virtual void
229
230 virtual double
232
236 virtual void
238 {
239 this->m_MaximumUpdateStepLength = sm;
240 }
241
242 virtual double
244 {
245 return this->m_MaximumUpdateStepLength;
246 }
247
249#if !defined(ITK_LEGACY_REMOVE)
251 static constexpr GradientEnum Symmetric = GradientEnum::Symmetric;
252 static constexpr GradientEnum Fixed = GradientEnum::Fixed;
253 static constexpr GradientEnum WarpedMoving = GradientEnum::WarpedMoving;
254 static constexpr GradientEnum MappedMoving = GradientEnum::MappedMoving;
255#endif
256
259 virtual void
261 {
262 m_UseGradientType = gtype;
263 }
264 virtual GradientEnum
266 {
267 return m_UseGradientType;
268 }
269
270
271protected:
273 ~ESMDemonsRegistrationFunction() override = default;
274 void
275 PrintSelf(std::ostream & os, Indent indent) const override;
276
279
288
289private:
294 double m_Normalizer{};
295
298
301
303
306
309
311
314
317
320
323
327 mutable double m_Metric{};
328 mutable double m_SumOfSquaredDifference{};
330 mutable double m_RMSChange{};
331 mutable double m_SumOfSquaredChange{};
332
334 mutable std::mutex m_MetricCalculationMutex{};
335};
336} // end namespace itk
337
338#ifndef ITK_MANUAL_INSTANTIATION
339# include "itkESMDemonsRegistrationFunction.hxx"
340#endif
341
342#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.
WarpImageFilter< MovingImageType, MovingImageType, DisplacementFieldType > WarperType
TimeStepType ComputeGlobalTimeStep(void *GlobalData) const override
~ESMDemonsRegistrationFunction() override=default
virtual double GetIntensityDifferenceThreshold() const
virtual void SetUseGradientType(GradientEnum gtype)
CentralDifferenceImageFunction< MovingImageType, CoordinateType > MovingImageGradientCalculatorType
PDEDeformableRegistrationFunction< FixedImageType, MovingImageType, DisplacementFieldType > Superclass
void ReleaseGlobalDataPointer(void *gd) const override
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
ConstNeighborhoodIterator< TImageType, DefaultBoundaryConditionType > NeighborhoodType
static constexpr unsigned int ImageDimension
Vector< float, Self::ImageDimension > FloatOffsetType
typename ImageType::PixelType PixelType
typename ConstNeighborhoodIterator< TImageType >::RadiusType RadiusType
Control indentation during Print() invocation.
Definition itkIndent.h:51
Base class for all image interpolators.
Point< CoordinateType, Self::ImageDimension > PointType
Linearly interpolate an image at specified positions.
Implements transparent reference counting.
Warps an image using an input displacement field.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType
Definition itkIntTypes.h:86
ITKCommon_EXPORT std::ostream & operator<<(std::ostream &out, AnatomicalOrientation::CoordinateEnum value)