ITK  6.0.0
Insight Toolkit
itkLevelSetMotionRegistrationFunction.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 itkLevelSetMotionRegistrationFunction_h
19 #define itkLevelSetMotionRegistrationFunction_h
20 
22 #include "itkPoint.h"
23 #include "itkCovariantVector.h"
26 #include <mutex>
27 
28 namespace itk
29 {
54 template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
55 class ITK_TEMPLATE_EXPORT LevelSetMotionRegistrationFunction
56  : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
57 {
58 public:
59  ITK_DISALLOW_COPY_AND_MOVE(LevelSetMotionRegistrationFunction);
60 
64 
67 
69  itkNewMacro(Self);
70 
72  itkOverrideGetNameOfClassMacro(LevelSetMotionRegistrationFunction);
73 
75  using typename Superclass::MovingImageType;
76  using typename Superclass::MovingImagePointer;
77  using MovingSpacingType = typename MovingImageType::SpacingType;
78 
80  using typename Superclass::FixedImageType;
81  using typename Superclass::FixedImagePointer;
84  using SpacingType = typename FixedImageType::SpacingType;
85 
87  using typename Superclass::DisplacementFieldType;
88  using typename Superclass::DisplacementFieldTypePointer;
89 
91  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
92 
94  using typename Superclass::PixelType;
95  using typename Superclass::RadiusType;
96  using typename Superclass::NeighborhoodType;
97  using typename Superclass::FloatOffsetType;
98  using typename Superclass::TimeStepType;
99 
101  using CoordinateType = double;
102 #ifndef ITK_FUTURE_LEGACY_REMOVE
103  using CoordRepType ITK_FUTURE_DEPRECATED(
104  "ITK 6 discourages using `CoordRepType`. Please use `CoordinateType` instead!") = CoordinateType;
105 #endif
110 
114 
118 
120  void
122  {
123  m_MovingImageInterpolator = ptr;
124  }
125 
127  InterpolatorType *
129  {
130  return m_MovingImageInterpolator;
131  }
132 
137  TimeStepType
138  ComputeGlobalTimeStep(void * GlobalData) const override;
139 
142  void *
143  GetGlobalDataPointer() const override
144  {
145  auto * global = new GlobalDataStruct();
146 
147  global->m_SumOfSquaredDifference = 0.0;
148  global->m_NumberOfPixelsProcessed = 0L;
149  global->m_SumOfSquaredChange = 0;
150  global->m_MaxL1Norm = NumericTraits<double>::NonpositiveMin();
151  return global;
152  }
153 
158  void
159  ReleaseGlobalDataPointer(void * gd) const override;
160 
162  void
163  InitializeIteration() override;
164 
169  PixelType
170  ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
171 
175  virtual double
176  GetMetric() const
177  {
178  return m_Metric;
179  }
180 
182  virtual double
183  GetRMSChange() const
184  {
185  return m_RMSChange;
186  }
187 
194  virtual void
195  SetAlpha(double);
196 
197  virtual double
198  GetAlpha() const;
199 
204  virtual void
205  SetIntensityDifferenceThreshold(double);
206 
207  virtual double
208  GetIntensityDifferenceThreshold() const;
209 
212  virtual void
213  SetGradientMagnitudeThreshold(double);
214 
215  virtual double
216  GetGradientMagnitudeThreshold() const;
217 
220  virtual void
221  SetGradientSmoothingStandardDeviations(double);
222 
223  virtual double
224  GetGradientSmoothingStandardDeviations() const;
225 
229  void
230  SetUseImageSpacing(bool);
231 
232  bool
233  GetUseImageSpacing() const;
234 
235 protected:
237  ~LevelSetMotionRegistrationFunction() override = default;
238  void
239  PrintSelf(std::ostream & os, Indent indent) const override;
240 
243 
247  {
251  double m_MaxL1Norm;
252  };
253 
254 private:
256  SpacingType m_FixedImageSpacing{};
257  PointType m_FixedImageOrigin{};
258 
260  MovingImageSmoothingFilterPointer m_MovingImageSmoothingFilter{};
261 
263  InterpolatorPointer m_MovingImageInterpolator{};
264  InterpolatorPointer m_SmoothMovingImageInterpolator{};
265 
268  double m_Alpha{};
269 
271  double m_GradientMagnitudeThreshold{};
272 
274  double m_IntensityDifferenceThreshold{};
275 
277  double m_GradientSmoothingStandardDeviations{};
278 
282  mutable double m_Metric{};
283  mutable double m_SumOfSquaredDifference{};
284  mutable SizeValueType m_NumberOfPixelsProcessed{};
285  mutable double m_RMSChange{};
286  mutable double m_SumOfSquaredChange{};
287 
289  mutable std::mutex m_MetricCalculationMutex{};
290 
291  bool m_UseImageSpacing{ true };
292 };
293 } // end namespace itk
294 
295 #ifndef ITK_MANUAL_INSTANTIATION
296 # include "itkLevelSetMotionRegistrationFunction.hxx"
297 #endif
298 
299 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::LevelSetMotionRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkLevelSetMotionRegistrationFunction.h:84
itkCovariantVector.h
itkLinearInterpolateImageFunction.h
itkSmoothingRecursiveGaussianImageFilter.h
itk::LevelSetMotionRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkLevelSetMotionRegistrationFunction.h:82
itkPoint.h
itk::LevelSetMotionRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkLevelSetMotionRegistrationFunction.h:121
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:99
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkPDEDeformableRegistrationFunction.h
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct
Definition: itkLevelSetMotionRegistrationFunction.h:246
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkLevelSetMotionRegistrationFunction.h:249
itk::LevelSetMotionRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkLevelSetMotionRegistrationFunction.h:108
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:51
itk::LevelSetMotionRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkLevelSetMotionRegistrationFunction.h:176
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LevelSetMotionRegistrationFunction::GetRMSChange
virtual double GetRMSChange() const
Definition: itkLevelSetMotionRegistrationFunction.h:183
itk::LevelSetMotionRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkLevelSetMotionRegistrationFunction.h:128
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkLevelSetMotionRegistrationFunction.h:250
itk::LevelSetMotionRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkLevelSetMotionRegistrationFunction.h:107
itk::LevelSetMotionRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkLevelSetMotionRegistrationFunction.h:143
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::LevelSetMotionRegistrationFunction::MovingSpacingType
typename MovingImageType::SpacingType MovingSpacingType
Definition: itkLevelSetMotionRegistrationFunction.h:77
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkLevelSetMotionRegistrationFunction.h:248
itk::LevelSetMotionRegistrationFunction::CoordinateType
double CoordinateType
Definition: itkLevelSetMotionRegistrationFunction.h:101
itk::LevelSetMotionRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkLevelSetMotionRegistrationFunction.h:83
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_MaxL1Norm
double m_MaxL1Norm
Definition: itkLevelSetMotionRegistrationFunction.h:251
itk::LevelSetMotionRegistrationFunction
Definition: itkLevelSetMotionRegistrationFunction.h:55
itk::FiniteDifferenceFunction< TDisplacementField >
itk::LevelSetMotionRegistrationFunction::MovingImageSmoothingFilterPointer
typename MovingImageSmoothingFilterType::Pointer MovingImageSmoothingFilterPointer
Definition: itkLevelSetMotionRegistrationFunction.h:117
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SmoothingRecursiveGaussianImageFilter
Computes the smoothing of an image by convolution with the Gaussian kernels implemented as IIR filter...
Definition: itkSmoothingRecursiveGaussianImageFilter.h:50
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90