ITK  5.4.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 CoordRepType = double;
106 
110 
114 
116  void
118  {
119  m_MovingImageInterpolator = ptr;
120  }
121 
123  InterpolatorType *
125  {
126  return m_MovingImageInterpolator;
127  }
128 
133  TimeStepType
134  ComputeGlobalTimeStep(void * GlobalData) const override;
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  global->m_MaxL1Norm = NumericTraits<double>::NonpositiveMin();
147  return global;
148  }
149 
154  void
155  ReleaseGlobalDataPointer(void * gd) const override;
156 
158  void
159  InitializeIteration() override;
160 
165  PixelType
166  ComputeUpdate(const NeighborhoodType & it, void * gd, const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
167 
171  virtual double
172  GetMetric() const
173  {
174  return m_Metric;
175  }
176 
178  virtual double
179  GetRMSChange() const
180  {
181  return m_RMSChange;
182  }
183 
190  virtual void
191  SetAlpha(double);
192 
193  virtual double
194  GetAlpha() const;
195 
200  virtual void
201  SetIntensityDifferenceThreshold(double);
202 
203  virtual double
204  GetIntensityDifferenceThreshold() const;
205 
208  virtual void
209  SetGradientMagnitudeThreshold(double);
210 
211  virtual double
212  GetGradientMagnitudeThreshold() const;
213 
216  virtual void
217  SetGradientSmoothingStandardDeviations(double);
218 
219  virtual double
220  GetGradientSmoothingStandardDeviations() const;
221 
225  void
226  SetUseImageSpacing(bool);
227 
228  bool
229  GetUseImageSpacing() const;
230 
231 protected:
233  ~LevelSetMotionRegistrationFunction() override = default;
234  void
235  PrintSelf(std::ostream & os, Indent indent) const override;
236 
239 
243  {
247  double m_MaxL1Norm;
248  };
249 
250 private:
252  SpacingType m_FixedImageSpacing{};
253  PointType m_FixedImageOrigin{};
254 
256  MovingImageSmoothingFilterPointer m_MovingImageSmoothingFilter{};
257 
259  InterpolatorPointer m_MovingImageInterpolator{};
260  InterpolatorPointer m_SmoothMovingImageInterpolator{};
261 
264  double m_Alpha{};
265 
267  double m_GradientMagnitudeThreshold{};
268 
270  double m_IntensityDifferenceThreshold{};
271 
273  double m_GradientSmoothingStandardDeviations{};
274 
278  mutable double m_Metric{};
279  mutable double m_SumOfSquaredDifference{};
280  mutable SizeValueType m_NumberOfPixelsProcessed{};
281  mutable double m_RMSChange{};
282  mutable double m_SumOfSquaredChange{};
283 
285  mutable std::mutex m_MetricCalculationMutex{};
286 
287  bool m_UseImageSpacing{ true };
288 };
289 } // end namespace itk
290 
291 #ifndef ITK_MANUAL_INSTANTIATION
292 # include "itkLevelSetMotionRegistrationFunction.hxx"
293 #endif
294 
295 #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:117
itk::NumericTraits::NonpositiveMin
static constexpr T NonpositiveMin()
Definition: itkNumericTraits.h:98
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:242
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:245
itk::LevelSetMotionRegistrationFunction::CoordRepType
double CoordRepType
Definition: itkLevelSetMotionRegistrationFunction.h:101
itk::LevelSetMotionRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkLevelSetMotionRegistrationFunction.h:104
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:172
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itk::LevelSetMotionRegistrationFunction::GetRMSChange
virtual double GetRMSChange() const
Definition: itkLevelSetMotionRegistrationFunction.h:179
itk::LevelSetMotionRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkLevelSetMotionRegistrationFunction.h:124
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkLevelSetMotionRegistrationFunction.h:246
itk::LevelSetMotionRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkLevelSetMotionRegistrationFunction.h:103
itk::LevelSetMotionRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkLevelSetMotionRegistrationFunction.h:139
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: itkAnnulusOperator.h:24
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:244
itk::LevelSetMotionRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkLevelSetMotionRegistrationFunction.h:83
itk::LevelSetMotionRegistrationFunction::GlobalDataStruct::m_MaxL1Norm
double m_MaxL1Norm
Definition: itkLevelSetMotionRegistrationFunction.h:247
itk::LevelSetMotionRegistrationFunction
Definition: itkLevelSetMotionRegistrationFunction.h:55
itk::FiniteDifferenceFunction< TDisplacementField >
itk::LevelSetMotionRegistrationFunction::MovingImageSmoothingFilterPointer
typename MovingImageSmoothingFilterType::Pointer MovingImageSmoothingFilterPointer
Definition: itkLevelSetMotionRegistrationFunction.h:113
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:83
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90