ITK  5.2.0
Insight Toolkit
itkInvertDisplacementFieldImageFilter.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 itkInvertDisplacementFieldImageFilter_h
19 #define itkInvertDisplacementFieldImageFilter_h
20 
21 #include "itkImageToImageFilter.h"
24 #include <mutex>
25 
26 namespace itk
27 {
28 
40 template <typename TInputImage, typename TOutputImage = TInputImage>
41 class ITK_TEMPLATE_EXPORT InvertDisplacementFieldImageFilter : public ImageToImageFilter<TInputImage, TOutputImage>
42 {
43 public:
44  ITK_DISALLOW_COPY_AND_MOVE(InvertDisplacementFieldImageFilter);
45 
50 
52  itkNewMacro(Self);
53 
55  static constexpr unsigned int ImageDimension = TInputImage::ImageDimension;
56 
57  using InputFieldType = TInputImage;
58  using OutputFieldType = TOutputImage;
59 
62 
64  using PixelType = typename OutputFieldType::PixelType;
65  using VectorType = typename OutputFieldType::PixelType;
69 
71  using SpacingType = typename OutputFieldType::SpacingType;
75 
77  using RealType = typename VectorType::ComponentType;
81 
83  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
84 
86  void
88  {
89  itkDebugMacro("setting deformation field to " << field);
90  if (field != this->GetInput(0))
91  {
92  this->SetInput(0, field);
93  this->Modified();
94  if (!this->m_Interpolator.IsNull())
95  {
96  this->m_Interpolator->SetInputImage(field);
97  }
98  }
99  }
101 
105  const InputFieldType *
107  {
108  return this->GetInput(0);
109  }
110 
112  itkSetInputMacro(InverseFieldInitialEstimate, InverseDisplacementFieldType);
113  itkGetInputMacro(InverseFieldInitialEstimate, InverseDisplacementFieldType);
115 
116  /* Set the interpolator. */
117  virtual void
118  SetInterpolator(InterpolatorType * interpolator);
119 
120  /* Set/Get the number of iterations */
121  itkSetMacro(MaximumNumberOfIterations, unsigned int);
122  itkGetConstMacro(MaximumNumberOfIterations, unsigned int);
123 
124  /* Set/Get the mean stopping criterion */
125  itkSetMacro(MeanErrorToleranceThreshold, RealType);
126  itkGetConstMacro(MeanErrorToleranceThreshold, RealType);
127 
128  /* Set/Get the max stopping criterion */
129  itkSetMacro(MaxErrorToleranceThreshold, RealType);
130  itkGetConstMacro(MaxErrorToleranceThreshold, RealType);
131 
132  /* Get the max norm */
133  itkGetConstMacro(MaxErrorNorm, RealType);
134 
135  /* Get the mean norm */
136  itkGetConstMacro(MeanErrorNorm, RealType);
137 
138  /* Should we force the boundary to have zero displacement? */
139  itkSetMacro(EnforceBoundaryCondition, bool);
140  itkGetMacro(EnforceBoundaryCondition, bool);
141 
142 protected:
145 
147  ~InvertDisplacementFieldImageFilter() override = default;
148 
150  void
151  PrintSelf(std::ostream & os, Indent indent) const override;
152 
154  void
155  GenerateData() override;
156 
158  void
159  DynamicThreadedGenerateData(const RegionType &) override;
160 
161 private:
164 
165  unsigned int m_MaximumNumberOfIterations{ 20 };
166 
169 
170  // internal ivars necessary for multithreading basic operations
171 
172  typename DisplacementFieldType::Pointer m_ComposedField;
174 
179  bool m_DoThreadedEstimateInverse{ false };
180  bool m_EnforceBoundaryCondition{ true };
181  std::mutex m_Mutex;
182 };
183 
184 } // end namespace itk
185 
186 #ifndef ITK_MANUAL_INSTANTIATION
187 # include "itkInvertDisplacementFieldImageFilter.hxx"
188 #endif
189 
190 #endif
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::InvertDisplacementFieldImageFilter::DisplacementFieldType
InputFieldType DisplacementFieldType
Definition: itkInvertDisplacementFieldImageFilter.h:60
itk::InvertDisplacementFieldImageFilter::SetDisplacementField
void SetDisplacementField(const InputFieldType *field)
Definition: itkInvertDisplacementFieldImageFilter.h:87
itk::InvertDisplacementFieldImageFilter::m_Epsilon
RealType m_Epsilon
Definition: itkInvertDisplacementFieldImageFilter.h:177
itk::InvertDisplacementFieldImageFilter::PixelType
typename OutputFieldType::PixelType PixelType
Definition: itkInvertDisplacementFieldImageFilter.h:64
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::InvertDisplacementFieldImageFilter::m_MeanErrorToleranceThreshold
RealType m_MeanErrorToleranceThreshold
Definition: itkInvertDisplacementFieldImageFilter.h:168
itk::InvertDisplacementFieldImageFilter::PointType
typename OutputFieldType::PointType PointType
Definition: itkInvertDisplacementFieldImageFilter.h:70
itk::InvertDisplacementFieldImageFilter::m_ComposedField
DisplacementFieldType::Pointer m_ComposedField
Definition: itkInvertDisplacementFieldImageFilter.h:172
itk::InvertDisplacementFieldImageFilter::VectorType
typename OutputFieldType::PixelType VectorType
Definition: itkInvertDisplacementFieldImageFilter.h:65
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itkVectorLinearInterpolateImageFunction.h
itk::VectorInterpolateImageFunction
Base class for all vector image interpolators.
Definition: itkVectorInterpolateImageFunction.h:47
itk::InvertDisplacementFieldImageFilter::IndexType
typename OutputFieldType::IndexType IndexType
Definition: itkInvertDisplacementFieldImageFilter.h:68
itk::InvertDisplacementFieldImageFilter::RegionType
typename OutputFieldType::RegionType RegionType
Definition: itkInvertDisplacementFieldImageFilter.h:66
itk::InvertDisplacementFieldImageFilter::m_DisplacementFieldSpacing
SpacingType m_DisplacementFieldSpacing
Definition: itkInvertDisplacementFieldImageFilter.h:178
itk::InvertDisplacementFieldImageFilter::RealType
typename VectorType::ComponentType RealType
Definition: itkInvertDisplacementFieldImageFilter.h:77
itk::InvertDisplacementFieldImageFilter::m_MeanErrorNorm
RealType m_MeanErrorNorm
Definition: itkInvertDisplacementFieldImageFilter.h:176
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::ImageToImageFilter
Base class for filters that take an image as input and produce an image as output.
Definition: itkImageToImageFilter.h:108
itk::InvertDisplacementFieldImageFilter::DirectionType
typename OutputFieldType::DirectionType DirectionType
Definition: itkInvertDisplacementFieldImageFilter.h:74
itk::ImageSource
Base class for all process objects that output image data.
Definition: itkImageSource.h:67
itk::InvertDisplacementFieldImageFilter::SizeType
typename OutputFieldType::SizeType SizeType
Definition: itkInvertDisplacementFieldImageFilter.h:73
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::InvertDisplacementFieldImageFilter::InverseDisplacementFieldType
OutputFieldType InverseDisplacementFieldType
Definition: itkInvertDisplacementFieldImageFilter.h:61
itkVectorInterpolateImageFunction.h
itkImageToImageFilter.h
itk::InvertDisplacementFieldImageFilter::m_Interpolator
InterpolatorType::Pointer m_Interpolator
Definition: itkInvertDisplacementFieldImageFilter.h:163
itk::InvertDisplacementFieldImageFilter::SpacingType
typename OutputFieldType::SpacingType SpacingType
Definition: itkInvertDisplacementFieldImageFilter.h:71
itk::InvertDisplacementFieldImageFilter::OriginType
typename OutputFieldType::PointType OriginType
Definition: itkInvertDisplacementFieldImageFilter.h:72
itk::ImageSource::OutputImageRegionType
typename OutputImageType::RegionType OutputImageRegionType
Definition: itkImageSource.h:92
itk::InvertDisplacementFieldImageFilter::OutputFieldType
TOutputImage OutputFieldType
Definition: itkInvertDisplacementFieldImageFilter.h:58
itk::InvertDisplacementFieldImageFilter::m_ScaledNormImage
RealImageType::Pointer m_ScaledNormImage
Definition: itkInvertDisplacementFieldImageFilter.h:173
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::InvertDisplacementFieldImageFilter::m_MaxErrorNorm
RealType m_MaxErrorNorm
Definition: itkInvertDisplacementFieldImageFilter.h:175
itk::ProcessObject
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
Definition: itkProcessObject.h:138
itk::InvertDisplacementFieldImageFilter::m_MaxErrorToleranceThreshold
RealType m_MaxErrorToleranceThreshold
Definition: itkInvertDisplacementFieldImageFilter.h:167
itk::InvertDisplacementFieldImageFilter
Iteratively estimate the inverse field of a displacement field.
Definition: itkInvertDisplacementFieldImageFilter.h:41
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::InvertDisplacementFieldImageFilter::InputFieldType
TInputImage InputFieldType
Definition: itkInvertDisplacementFieldImageFilter.h:57
itk::InvertDisplacementFieldImageFilter::m_Mutex
std::mutex m_Mutex
Definition: itkInvertDisplacementFieldImageFilter.h:181
itk::InvertDisplacementFieldImageFilter::GetDisplacementField
const InputFieldType * GetDisplacementField() const
Definition: itkInvertDisplacementFieldImageFilter.h:106
itk::VectorLinearInterpolateImageFunction
Linearly interpolate a vector image at specified positions.
Definition: itkVectorLinearInterpolateImageFunction.h:43