ITK  6.0.0
Insight Toolkit
itkFastSymmetricForcesDemonsRegistrationFunction.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 itkFastSymmetricForcesDemonsRegistrationFunction_h
19 #define itkFastSymmetricForcesDemonsRegistrationFunction_h
20 
22 #include "itkPoint.h"
25 #include "itkWarpImageFilter.h"
26 #include <mutex>
27 
28 namespace itk
29 {
46 template <typename TFixedImage, typename TMovingImage, typename TDisplacementField>
48  : public PDEDeformableRegistrationFunction<TFixedImage, TMovingImage, TDisplacementField>
49 {
50 public:
51  ITK_DISALLOW_COPY_AND_MOVE(FastSymmetricForcesDemonsRegistrationFunction);
52 
58 
60  itkNewMacro(Self);
61 
63  itkOverrideGetNameOfClassMacro(FastSymmetricForcesDemonsRegistrationFunction);
64 
66  using typename Superclass::MovingImageType;
67  using typename Superclass::MovingImagePointer;
68 
70  using typename Superclass::FixedImageType;
71  using typename Superclass::FixedImagePointer;
74  using SpacingType = typename FixedImageType::SpacingType;
75 
77  using typename Superclass::DisplacementFieldType;
78  using typename Superclass::DisplacementFieldTypePointer;
79 
81  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
82 
84  using typename Superclass::PixelType;
85  using typename Superclass::RadiusType;
86  using typename Superclass::NeighborhoodType;
87  using typename Superclass::FloatOffsetType;
88  using typename Superclass::TimeStepType;
89 
91  using CoordRepType = double;
96 
100 
103 
107 
110 
112  void
114  {
115  m_MovingImageInterpolator = ptr;
116  m_MovingImageWarper->SetInterpolator(ptr);
117  }
121  InterpolatorType *
123  {
124  return m_MovingImageInterpolator;
125  }
126 
128  TimeStepType
129  ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
130  {
131  return m_TimeStep;
132  }
133 
136  void *
137  GetGlobalDataPointer() const override
138  {
139  auto * global = new GlobalDataStruct();
140 
141  global->m_SumOfSquaredDifference = 0.0;
142  global->m_NumberOfPixelsProcessed = 0L;
143  global->m_SumOfSquaredChange = 0;
144  return global;
145  }
146 
151  void
152  ReleaseGlobalDataPointer(void * GlobalData) const override;
153 
155  void
156  InitializeIteration() override;
157 
162  PixelType
163  ComputeUpdate(const NeighborhoodType & neighborhood,
164  void * globalData,
165  const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
166 
170  virtual double
171  GetMetric() const
172  {
173  return m_Metric;
174  }
175 
177  virtual const double &
178  GetRMSChange() const
179  {
180  return m_RMSChange;
181  }
182 
187  virtual void
188  SetIntensityDifferenceThreshold(double);
189 
190  virtual double
191  GetIntensityDifferenceThreshold() const;
192 
193 protected:
195  ~FastSymmetricForcesDemonsRegistrationFunction() override = default;
196  void
197  PrintSelf(std::ostream & os, Indent indent) const override;
198 
201 
205  {
209  };
210 
211 private:
213  double m_Normalizer{};
214 
216  GradientCalculatorPointer m_FixedImageGradientCalculator{};
217 
219  MovingGradientCalculatorPointer m_WarpedMovingImageGradientCalculator{};
220 
222  InterpolatorPointer m_MovingImageInterpolator{};
223 
225  WarperPointer m_MovingImageWarper{};
226 
228  TimeStepType m_TimeStep{};
229 
231  double m_DenominatorThreshold{};
232 
234  double m_IntensityDifferenceThreshold{};
235 
239  mutable double m_Metric{};
240  mutable double m_SumOfSquaredDifference{};
241  mutable SizeValueType m_NumberOfPixelsProcessed{};
242  mutable double m_RMSChange{};
243  mutable double m_SumOfSquaredChange{};
244 
246  mutable std::mutex m_MetricCalculationMutex{};
247 };
248 } // end namespace itk
249 
250 #ifndef ITK_MANUAL_INSTANTIATION
251 # include "itkFastSymmetricForcesDemonsRegistrationFunction.hxx"
252 #endif
253 
254 #endif
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::FastSymmetricForcesDemonsRegistrationFunction::GetRMSChange
virtual const double & GetRMSChange() const
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:178
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:207
itkPoint.h
itk::FastSymmetricForcesDemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:122
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itkPDEDeformableRegistrationFunction.h
itk::CentralDifferenceImageFunction
Calculate the derivative by central differencing.
Definition: itkCentralDifferenceImageFunction.h:76
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::FastSymmetricForcesDemonsRegistrationFunction
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:47
itk::FastSymmetricForcesDemonsRegistrationFunction::WarperPointer
typename WarperType::Pointer WarperPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:99
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::FastSymmetricForcesDemonsRegistrationFunction::GetGlobalDataPointer
void * GetGlobalDataPointer() const override
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:137
itk::FastSymmetricForcesDemonsRegistrationFunction::MovingGradientCalculatorPointer
typename MovingGradientCalculatorType::Pointer MovingGradientCalculatorPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:109
itk::FastSymmetricForcesDemonsRegistrationFunction::CoordRepType
double CoordRepType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:91
itkWarpImageFilter.h
itk::FastSymmetricForcesDemonsRegistrationFunction::SpacingType
typename FixedImageType::SpacingType SpacingType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:74
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:206
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::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:55
itkCentralDifferenceImageFunction.h
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:204
itk::FastSymmetricForcesDemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:94
itk::FastSymmetricForcesDemonsRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:73
itk::FastSymmetricForcesDemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:106
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::FastSymmetricForcesDemonsRegistrationFunction::ComputeGlobalTimeStep
TimeStepType ComputeGlobalTimeStep(void *) const override
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:129
itk::FastSymmetricForcesDemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:72
itk::FastSymmetricForcesDemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:113
itk::WarpImageFilter
Warps an image using an input displacement field.
Definition: itkWarpImageFilter.h:85
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::FiniteDifferenceFunction< TDisplacementField >
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:208
itkInterpolateImageFunction.h
itk::FastSymmetricForcesDemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:93
itk::FastSymmetricForcesDemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:171
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:86
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90