ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkESMDemonsRegistrationFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
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 itkESMDemonsRegistrationFunction_h
19 #define itkESMDemonsRegistrationFunction_h
20 
23 #include "itkWarpImageFilter.h"
24 #include <mutex>
25 
26 namespace itk
27 {
60 template< typename TFixedImage, typename TMovingImage, typename TDisplacementField >
61 class ITK_TEMPLATE_EXPORT ESMDemonsRegistrationFunction:
62  public PDEDeformableRegistrationFunction< TFixedImage,
63  TMovingImage, TDisplacementField >
64 {
65 public:
66  ITK_DISALLOW_COPY_AND_ASSIGN(ESMDemonsRegistrationFunction);
67 
71  TFixedImage, TMovingImage, TDisplacementField >;
72 
75 
77  itkNewMacro(Self);
78 
80  itkTypeMacro(ESMDemonsRegistrationFunction,
82 
84  using MovingImageType = typename Superclass::MovingImageType;
85  using MovingImagePointer = typename Superclass::MovingImagePointer;
86  using MovingPixelType = typename MovingImageType::PixelType;
87 
89  using FixedImageType = typename Superclass::FixedImageType;
90  using FixedImagePointer = typename Superclass::FixedImagePointer;
93  using SpacingType = typename FixedImageType::SpacingType;
95 
97  using DisplacementFieldType = typename Superclass::DisplacementFieldType;
98  using DisplacementFieldTypePointer = typename Superclass::DisplacementFieldTypePointer;
99 
101  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
102 
109 
111  using CoordRepType = double;
118 
120  using WarperType = WarpImageFilter<
123 
125 
128 
132 
137 
140  { m_MovingImageInterpolator = ptr; m_MovingImageWarper->SetInterpolator(ptr); }
141 
144  { return m_MovingImageInterpolator; }
145 
147  TimeStepType ComputeGlobalTimeStep( void *itkNotUsed(GlobalData) ) const override
148  { return m_TimeStep; }
149 
152  void * GetGlobalDataPointer() const override
153  {
154  auto * global = new GlobalDataStruct();
155 
156  global->m_SumOfSquaredDifference = 0.0;
157  global->m_NumberOfPixelsProcessed = 0L;
158  global->m_SumOfSquaredChange = 0;
159  return global;
160  }
161 
163  void ReleaseGlobalDataPointer(void *GlobalData) const override;
164 
166  void InitializeIteration() override;
167 
170  PixelType ComputeUpdate( const NeighborhoodType & neighborhood,
171  void *globalData,
172  const FloatOffsetType & offset = FloatOffsetType(0.0) ) override;
173 
177  virtual double GetMetric() const
178  { return m_Metric; }
179 
181  virtual const double & GetRMSChange() const
182  { return m_RMSChange; }
183 
188  virtual void SetIntensityDifferenceThreshold(double);
189 
190  virtual double GetIntensityDifferenceThreshold() const;
191 
195  virtual void SetMaximumUpdateStepLength(double sm)
196  {
197  this->m_MaximumUpdateStepLength = sm;
198  }
199 
200  virtual double GetMaximumUpdateStepLength() const
201  {
202  return this->m_MaximumUpdateStepLength;
203  }
204 
207  Symmetric = 0,
208  Fixed = 1,
209  WarpedMoving = 2,
210  MappedMoving = 3
211  };
212 
214  virtual void SetUseGradientType(GradientType gtype)
215  { m_UseGradientType = gtype; }
217  { return m_UseGradientType; }
219 
220 protected:
222  ~ESMDemonsRegistrationFunction() override = default;
223  void PrintSelf(std::ostream & os, Indent indent) const override;
224 
227 
234  };
235 
236 private:
241  double m_Normalizer;
242 
245 
248 
250 
253 
256 
258 
261 
264 
267 
270 
274  mutable double m_Metric;
275  mutable double m_SumOfSquaredDifference;
277  mutable double m_RMSChange;
278  mutable double m_SumOfSquaredChange;
279 
281  mutable std::mutex m_MetricCalculationLock;
282 };
283 } // end namespace itk
284 
285 #ifndef ITK_MANUAL_INSTANTIATION
286 #include "itkESMDemonsRegistrationFunction.hxx"
287 #endif
288 
289 #endif
typename FixedImageType::DirectionType DirectionType
typename MovingImageType::PixelType MovingPixelType
Light weight base class for most itk classes.
typename Superclass::FloatOffsetType FloatOffsetType
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename FixedImageType::SizeType SizeType
typename DisplacementFieldType::Pointer DisplacementFieldTypePointer
typename FixedImageType::SpacingType SpacingType
virtual void SetUseGradientType(GradientType gtype)
Calculate the derivative by central differencing.
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
TimeStepType ComputeGlobalTimeStep(void *) const override
typename ConstNeighborhoodIterator< TDisplacementField >::RadiusType RadiusType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
typename InterpolatorType::PointType PointType
MovingImageGradientCalculatorPointer m_MappedMovingImageGradientCalculator
typename MovingImageGradientCalculatorType::Pointer MovingImageGradientCalculatorPointer
typename MovingImageType::ConstPointer MovingImagePointer
typename Superclass::NeighborhoodType NeighborhoodType
typename Superclass::TimeStepType TimeStepType
Warps an image using an input displacement field.
Linearly interpolate an image at specified positions.
Base class for all image interpolaters.
typename Superclass::MovingImageType MovingImageType
typename InterpolatorType::Pointer InterpolatorPointer
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename FixedImageType::ConstPointer FixedImagePointer
A templated class holding a n-Dimensional covariant vector.
Fast implementation of the symmetric demons registration force.
typename GradientCalculatorType::Pointer GradientCalculatorPointer
typename FixedImageType::IndexType IndexType