ITK  5.0.0
Insight Segmentation and Registration Toolkit
itkVariationalRegistrationFunction.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 itkVariationalRegistrationFunction_h
19 #define itkVariationalRegistrationFunction_h
20 
22 //#include "itkWarpImageFilter.h"
24 #include <mutex>
25 
26 namespace itk {
27 
50 template< typename TFixedImage, typename TMovingImage, typename TDisplacementField>
52  public FiniteDifferenceFunction< TDisplacementField >
53 {
54 public:
55  ITK_DISALLOW_COPY_AND_ASSIGN(VariationalRegistrationFunction);
56 
62 
64 
67 
69  static constexpr unsigned int ImageDimension = Superclass::ImageDimension;
70 
72  using MovingImageType = TMovingImage;
73  using MovingImagePointer = typename MovingImageType::ConstPointer;
74 
76  using FixedImageType = TFixedImage;
77  using FixedImagePointer = typename FixedImageType::ConstPointer;
78 
80  using WarpedImageType = TFixedImage;
81  using WarpedImagePointer = typename WarpedImageType::ConstPointer;
82 
84  using DisplacementFieldType = TDisplacementField;
85  using DisplacementFieldTypePointer = typename DisplacementFieldType::ConstPointer;
86 
88  using MaskImagePixelType = unsigned char;
91 
92  // uncomment the following line to use the standard ITK warper (not recommended)
93  //typedef itk::WarpImageFilter< FixedImageType, WarpedImageType, DisplacementFieldType >
97 
98 
100  virtual void SetMovingImage( const MovingImageType * ptr )
101  { m_MovingImage = ptr; }
102 
104  virtual const MovingImageType * GetMovingImage(void) const
105  { return m_MovingImage; }
106 
108  virtual void SetFixedImage( const FixedImageType * ptr )
109  { m_FixedImage = ptr; }
110 
112  virtual const FixedImageType * GetFixedImage(void) const
113  { return m_FixedImage; }
114 
117  { m_DisplacementField = ptr; }
118 
120  virtual const DisplacementFieldType * GetDisplacementField(void) const
121  { return m_DisplacementField; }
122 
124  virtual void SetMaskImage( const MaskImageType * ptr )
125  { m_MaskImage = ptr; }
126 
128  virtual const MaskImageType * GetMaskImage(void) const
129  { return m_MaskImage; }
130 
133  { m_MovingImageWarper = ptr; }
134 
136  virtual const MovingImageWarperType * GetMovingImageWarper(void) const
137  { return m_MovingImageWarper; }
138 
140  virtual void SetTimeStep( TimeStepType timeStep )
141  { m_TimeStep = timeStep; }
142 
144  virtual const TimeStepType GetTimeStep(void) const
145  { return m_TimeStep; }
146 
150  { m_MaskBackgroundThreshold = threshold; }
151 
155  { return m_MaskBackgroundThreshold; }
156 
158  void InitializeIteration() override;
159 
163  TimeStepType ComputeGlobalTimeStep(void * itkNotUsed(GlobalData)) const override
164  { return m_TimeStep; }
165 
168  void *GetGlobalDataPointer() const override;
169 
171  void ReleaseGlobalDataPointer(void *GlobalData) const override;
172 
173  //
174  // Metric accessor methods
178  virtual double GetMetric() const
179  { return m_Metric; }
180 
182  virtual double GetRMSChange() const
183  { return m_RMSChange; }
184 
185 protected:
188 
190  void PrintSelf(std::ostream& os, Indent indent) const override;
191 
194  virtual void WarpMovingImage(void);
195 
197  virtual const WarpedImagePointer GetWarpedImage(void) const;
198 
202  {
206  };
207 
208 private:
211 
214 
217 
220 
223 
226 
229 
233  mutable double m_Metric;
234  mutable double m_SumOfMetricValues;
236  mutable double m_RMSChange;
237  mutable double m_SumOfSquaredChange;
238 
240  mutable std::mutex m_MetricCalculationLock;
241 };
242 
243 } // end namespace itk
244 
245 #ifndef ITK_MANUAL_INSTANTIATION
246 #include "itkVariationalRegistrationFunction.hxx"
247 #endif
248 
249 #endif
Base class for force calculation in the variational registration framework.
Light weight base class for most itk classes.
TimeStepType ComputeGlobalTimeStep(void *) const override
typename WarpedImageType::ConstPointer WarpedImagePointer
typename MaskImageType::ConstPointer MaskImagePointer
unsigned long SizeValueType
Definition: itkIntTypes.h:83
typename DisplacementFieldType::ConstPointer DisplacementFieldTypePointer
virtual const MaskImageType * GetMaskImage(void) const
virtual const WarpedImagePointer GetWarpedImage(void) const
virtual const MovingImageWarperType * GetMovingImageWarper(void) const
virtual const DisplacementFieldType * GetDisplacementField(void) const
virtual void SetMaskImage(const MaskImageType *ptr)
virtual void SetMovingImageWarper(MovingImageWarperType *ptr)
virtual const FixedImageType * GetFixedImage(void) const
virtual const MovingImageType * GetMovingImage(void) const
virtual MaskImagePixelType GetMaskBackgroundThreshold(void) const
void * GetGlobalDataPointer() const override
virtual const TimeStepType GetTimeStep(void) const
virtual void SetDisplacementField(DisplacementFieldType *ptr)
SmartPointer< const Self > ConstPointer
Definition: itkImage.h:84
typename FixedImageType::ConstPointer FixedImagePointer
void ReleaseGlobalDataPointer(void *GlobalData) const override
Warps an image using an input deformation field with continuous boundary conditions.
Control indentation during Print() invocation.
Definition: itkIndent.h:49
typename MovingImageType::ConstPointer MovingImagePointer
virtual void SetMovingImage(const MovingImageType *ptr)
typename MovingImageWarperType::Pointer MovingImageWarperPointer
virtual void SetFixedImage(const FixedImageType *ptr)
Templated n-dimensional image class.
Definition: itkImage.h:75
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void SetMaskBackgroundThreshold(MaskImagePixelType threshold)