ITK  5.2.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  * http://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 
64 
66  using MovingImageType = typename Superclass::MovingImageType;
67  using MovingImagePointer = typename Superclass::MovingImagePointer;
68 
70  using FixedImageType = typename Superclass::FixedImageType;
71  using FixedImagePointer = typename Superclass::FixedImagePointer;
74  using SpacingType = typename FixedImageType::SpacingType;
75 
77  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
78  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
79 
81  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
82 
84  using PixelType = typename Superclass::PixelType;
89 
91  using CoordRepType = double;
96 
100 
103 
107 
110 
112  void
114  {
115  m_MovingImageInterpolator = ptr;
116  m_MovingImageWarper->SetInterpolator(ptr);
117  }
119 
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 
148  void
149  ReleaseGlobalDataPointer(void * GlobalData) const override;
150 
152  void
153  InitializeIteration() override;
154 
157  PixelType
158  ComputeUpdate(const NeighborhoodType & neighborhood,
159  void * globalData,
160  const FloatOffsetType & offset = FloatOffsetType(0.0)) override;
161 
165  virtual double
166  GetMetric() const
167  {
168  return m_Metric;
169  }
170 
172  virtual const double &
173  GetRMSChange() const
174  {
175  return m_RMSChange;
176  }
177 
182  virtual void
183  SetIntensityDifferenceThreshold(double);
184 
185  virtual double
186  GetIntensityDifferenceThreshold() const;
187 
188 protected:
190  ~FastSymmetricForcesDemonsRegistrationFunction() override = default;
191  void
192  PrintSelf(std::ostream & os, Indent indent) const override;
193 
196 
200  {
204  };
205 
206 private:
208  double m_Normalizer;
209 
212 
215 
218 
221 
224 
227 
230 
234  mutable double m_Metric;
235  mutable double m_SumOfSquaredDifference;
237  mutable double m_RMSChange;
238  mutable double m_SumOfSquaredChange;
239 
241  mutable std::mutex m_MetricCalculationLock;
242 };
243 } // end namespace itk
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 # include "itkFastSymmetricForcesDemonsRegistrationFunction.hxx"
247 #endif
248 
249 #endif
itk::FastSymmetricForcesDemonsRegistrationFunction::m_TimeStep
TimeStepType m_TimeStep
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:223
itk::FastSymmetricForcesDemonsRegistrationFunction::GetRMSChange
virtual const double & GetRMSChange() const
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:173
itk::FiniteDifferenceFunction< TDisplacementField >::RadiusType
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
Definition: itkFiniteDifferenceFunction.h:97
itk::PDEDeformableRegistrationFunction::MovingImageType
TMovingImage MovingImageType
Definition: itkPDEDeformableRegistrationFunction.h:56
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:202
itk::PDEDeformableRegistrationFunction::MovingImagePointer
typename MovingImageType::ConstPointer MovingImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:57
itk::FastSymmetricForcesDemonsRegistrationFunction::FloatOffsetType
typename Superclass::FloatOffsetType FloatOffsetType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:87
itkPoint.h
itk::FastSymmetricForcesDemonsRegistrationFunction::GetMovingImageInterpolator
InterpolatorType * GetMovingImageInterpolator()
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:122
itk::FastSymmetricForcesDemonsRegistrationFunction::PixelType
typename Superclass::PixelType PixelType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:84
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::m_DenominatorThreshold
double m_DenominatorThreshold
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:226
itk::FastSymmetricForcesDemonsRegistrationFunction::m_Normalizer
double m_Normalizer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:208
itk::FastSymmetricForcesDemonsRegistrationFunction::TimeStepType
typename Superclass::TimeStepType TimeStepType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:88
itk::FastSymmetricForcesDemonsRegistrationFunction::m_FixedImageGradientCalculator
GradientCalculatorPointer m_FixedImageGradientCalculator
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:211
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:201
itk::FastSymmetricForcesDemonsRegistrationFunction::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:238
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LinearInterpolateImageFunction
Linearly interpolate an image at specified positions.
Definition: itkLinearInterpolateImageFunction.h:50
itk::FastSymmetricForcesDemonsRegistrationFunction::m_NumberOfPixelsProcessed
SizeValueType m_NumberOfPixelsProcessed
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:236
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itkCentralDifferenceImageFunction.h
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:199
itk::FastSymmetricForcesDemonsRegistrationFunction::PointType
typename InterpolatorType::PointType PointType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:94
itk::PDEDeformableRegistrationFunction::FixedImagePointer
typename FixedImageType::ConstPointer FixedImagePointer
Definition: itkPDEDeformableRegistrationFunction.h:61
itk::FastSymmetricForcesDemonsRegistrationFunction::m_Metric
double m_Metric
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:234
itk::FastSymmetricForcesDemonsRegistrationFunction::SizeType
typename FixedImageType::SizeType SizeType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:73
itk::FastSymmetricForcesDemonsRegistrationFunction::GradientCalculatorPointer
typename GradientCalculatorType::Pointer GradientCalculatorPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:106
itk::FastSymmetricForcesDemonsRegistrationFunction::m_MetricCalculationLock
std::mutex m_MetricCalculationLock
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:241
itk::FastSymmetricForcesDemonsRegistrationFunction::m_WarpedMovingImageGradientCalculator
MovingGradientCalculatorPointer m_WarpedMovingImageGradientCalculator
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:214
itk::PDEDeformableRegistrationFunction
Definition: itkPDEDeformableRegistrationFunction.h:41
itk::FiniteDifferenceFunction< TDisplacementField >::PixelType
typename ImageType::PixelType PixelType
Definition: itkFiniteDifferenceFunction.h:83
itk::FastSymmetricForcesDemonsRegistrationFunction::m_MovingImageWarper
WarperPointer m_MovingImageWarper
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:220
itk::FastSymmetricForcesDemonsRegistrationFunction::m_SumOfSquaredDifference
double m_SumOfSquaredDifference
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:235
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::PDEDeformableRegistrationFunction::DisplacementFieldTypePointer
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
Definition: itkPDEDeformableRegistrationFunction.h:65
itk::FastSymmetricForcesDemonsRegistrationFunction::IndexType
typename FixedImageType::IndexType IndexType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:72
itk::FastSymmetricForcesDemonsRegistrationFunction::SetMovingImageInterpolator
void SetMovingImageInterpolator(InterpolatorType *ptr)
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:113
itk::FastSymmetricForcesDemonsRegistrationFunction::m_IntensityDifferenceThreshold
double m_IntensityDifferenceThreshold
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:229
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: itkAnnulusOperator.h:24
itk::ConstNeighborhoodIterator
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
Definition: itkConstNeighborhoodIterator.h:51
itk::FastSymmetricForcesDemonsRegistrationFunction::m_RMSChange
double m_RMSChange
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:237
itk::PDEDeformableRegistrationFunction::FixedImageType
TFixedImage FixedImageType
Definition: itkPDEDeformableRegistrationFunction.h:60
itk::FastSymmetricForcesDemonsRegistrationFunction::RadiusType
typename Superclass::RadiusType RadiusType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:85
itk::FastSymmetricForcesDemonsRegistrationFunction::NeighborhoodType
typename Superclass::NeighborhoodType NeighborhoodType
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:86
itk::FiniteDifferenceFunction< TDisplacementField >
itk::FastSymmetricForcesDemonsRegistrationFunction::GlobalDataStruct::m_SumOfSquaredChange
double m_SumOfSquaredChange
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:203
itkInterpolateImageFunction.h
itk::FastSymmetricForcesDemonsRegistrationFunction::InterpolatorPointer
typename InterpolatorType::Pointer InterpolatorPointer
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:93
itk::PDEDeformableRegistrationFunction::DisplacementFieldType
TDisplacementField DisplacementFieldType
Definition: itkPDEDeformableRegistrationFunction.h:64
itk::FastSymmetricForcesDemonsRegistrationFunction::GetMetric
virtual double GetMetric() const
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:166
itk::FastSymmetricForcesDemonsRegistrationFunction::m_MovingImageInterpolator
InterpolatorPointer m_MovingImageInterpolator
Definition: itkFastSymmetricForcesDemonsRegistrationFunction.h:217
itk::InterpolateImageFunction
Base class for all image interpolators.
Definition: itkInterpolateImageFunction.h:45
itk::SizeValueType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
itk::FiniteDifferenceFunction< TDisplacementField >::TimeStepType
double TimeStepType
Definition: itkFiniteDifferenceFunction.h:90