ITK  6.0.0
Insight Toolkit
itkDisplacementFieldTransform.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 itkDisplacementFieldTransform_h
19 #define itkDisplacementFieldTransform_h
20 
21 #include "itkTransform.h"
22 
23 #include "itkImage.h"
24 #include "itkVectorImage.h"
28 
29 namespace itk
30 {
31 
86 template <typename TParametersValueType, unsigned int VDimension>
87 class ITK_TEMPLATE_EXPORT DisplacementFieldTransform : public Transform<TParametersValueType, VDimension, VDimension>
88 {
89 public:
90  ITK_DISALLOW_COPY_AND_MOVE(DisplacementFieldTransform);
91 
97 
99  itkOverrideGetNameOfClassMacro(DisplacementFieldTransform);
100 
102  itkNewMacro(Self);
103 
106 
108  using typename Superclass::ScalarType;
109 
111  using typename Superclass::FixedParametersType;
112  using typename Superclass::FixedParametersValueType;
113  using typename Superclass::ParametersType;
114  using typename Superclass::ParametersValueType;
115 
117  using typename Superclass::JacobianType;
118  using typename Superclass::JacobianPositionType;
120 
122  using typename Superclass::TransformCategoryEnum;
123 
125  using typename Superclass::NumberOfParametersType;
126 
128  using typename Superclass::InputPointType;
129  using typename Superclass::OutputPointType;
130 
132  using typename Superclass::InputVectorType;
133  using typename Superclass::OutputVectorType;
134 
135  using typename Superclass::InputVectorPixelType;
136  using typename Superclass::OutputVectorPixelType;
137 
141 
143  using typename Superclass::InputVnlVectorType;
144  using typename Superclass::OutputVnlVectorType;
145 
149 
153 
155  using typename Superclass::DerivativeType;
156 
158  static constexpr unsigned int Dimension = VDimension;
159 
165 
167 
176 
180 
185  virtual void
186  SetDisplacementField(DisplacementFieldType * field);
187  virtual void
188  SetDisplacementField(VectorImageDisplacementFieldType * field);
189  void SetDisplacementField(std::nullptr_t) = delete;
190  itkGetModifiableObjectMacro(DisplacementField, DisplacementFieldType);
195  virtual void
196  SetInverseDisplacementField(DisplacementFieldType * inverseField);
197  itkGetModifiableObjectMacro(InverseDisplacementField, DisplacementFieldType);
202  virtual void
203  SetInterpolator(InterpolatorType * interpolator);
204  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
209  virtual void
210  SetInverseInterpolator(InterpolatorType * interpolator);
211  itkGetModifiableObjectMacro(InverseInterpolator, InterpolatorType);
215  itkGetConstReferenceMacro(DisplacementFieldSetTime, ModifiedTimeType);
216 
220  TransformPoint(const InputPointType & inputPoint) const override;
221 
223  using Superclass::TransformVector;
225  TransformVector(const InputVectorType &) const override
226  {
227  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
228  "TransformVector(Vector,Point)");
229  }
232  OutputVectorPixelType
233  TransformVector(const InputVectorPixelType &) const override
234  {
235  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
236  "TransformVector(Vector,Point)");
237  }
238 
239  OutputVnlVectorType
240  TransformVector(const InputVnlVectorType &) const override
241  {
242  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
243  "TransformVector(Vector,Point)");
244  }
245 
247  using Superclass::TransformDiffusionTensor3D;
248  OutputDiffusionTensor3DType
250  {
251  itkExceptionMacro("TransformDiffusionTensor(Tensor) unimplemented, use "
252  "TransformDiffusionTensor(Tensor,Point)");
253  }
256  OutputVectorPixelType
258  {
259  itkExceptionMacro("TransformDiffusionTensor(Tensor) unimplemented, use "
260  "TransformDiffusionTensor(Tensor,Point)");
261  }
262 
264  using Superclass::TransformCovariantVector;
265  OutputCovariantVectorType
267  {
268  itkExceptionMacro("TransformCovariantVector(CovariantVector) "
269  "unimplemented, use TransformCovariantVector(CovariantVector,Point)");
270  }
273  OutputVectorPixelType
275  {
276  itkExceptionMacro("TransformCovariantVector(CovariantVector) "
277  "unimplemented, use TransformCovariantVector(CovariantVector,Point)");
278  }
279 
282  void
283  SetParameters(const ParametersType & params) override
284  {
285  if (&(this->m_Parameters) != &params)
286  {
287  if (params.Size() != this->m_Parameters.Size())
288  {
289  itkExceptionMacro("Input parameters size (" << params.Size() << ") does not match internal size ("
290  << this->m_Parameters.Size() << ").");
291  }
292  // Copy into existing object
293  this->m_Parameters = params;
294  this->Modified();
295  }
296  }
308  void
309  SetFixedParameters(const FixedParametersType &) override;
310 
332  void
334  {
335  j = this->m_IdentityJacobian;
336  }
345  virtual void
347  {
348  j = this->m_IdentityJacobian;
349  }
350 
355  void
356  ComputeJacobianWithRespectToPosition(const InputPointType & point, JacobianPositionType & jacobian) const override;
357  using Superclass::ComputeJacobianWithRespectToPosition;
358 
363  void
364  ComputeInverseJacobianWithRespectToPosition(const InputPointType & point,
365  InverseJacobianPositionType & jacobian) const override;
366  using Superclass::ComputeInverseJacobianWithRespectToPosition;
367 
372  virtual void
373  ComputeJacobianWithRespectToPosition(const IndexType & index, JacobianPositionType & jacobian) const;
374 
386  virtual void
387  GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
388  JacobianPositionType & jacobian,
389  bool useSVD = false) const;
390 
402  virtual void
403  GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index,
404  JacobianPositionType & jacobian,
405  bool useSVD = false) const;
406 
407  void
408  UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
409 
412  bool
413  GetInverse(Self * inverse) const;
414 
417  InverseTransformBasePointer
418  GetInverseTransform() const override;
419 
420  virtual void
421  SetIdentity();
422 
424  TransformCategoryEnum
425  GetTransformCategory() const override
426  {
427  return Self::TransformCategoryEnum::DisplacementField;
428  }
429 
430  NumberOfParametersType
431  GetNumberOfLocalParameters() const override
432  {
433  return Dimension;
434  }
435 
443  itkSetMacro(CoordinateTolerance, double);
444  itkGetConstMacro(CoordinateTolerance, double);
454  itkSetMacro(DirectionTolerance, double);
455  itkGetConstMacro(DirectionTolerance, double);
458 protected:
460  ~DisplacementFieldTransform() override = default;
461  void
462  PrintSelf(std::ostream & os, Indent indent) const override;
463 
465  typename DisplacementFieldType::Pointer m_DisplacementField{};
466  typename DisplacementFieldType::Pointer m_InverseDisplacementField{};
467 
469  typename InterpolatorType::Pointer m_Interpolator{};
470  typename InterpolatorType::Pointer m_InverseInterpolator{};
471 
474  ModifiedTimeType m_DisplacementFieldSetTime{ 0 };
475 
478  JacobianType m_IdentityJacobian{};
479 
480 private:
489  virtual void
490  ComputeJacobianWithRespectToPositionInternal(const IndexType & index,
491  JacobianPositionType & jacobian,
492  bool doInverseJacobian) const;
493 
498  virtual void
499  VerifyFixedParametersInformation();
500 
505  virtual void
506  SetFixedParametersFromDisplacementField() const;
507 
508  double m_CoordinateTolerance{};
509  double m_DirectionTolerance{};
510 };
511 
512 } // end namespace itk
513 
514 #ifndef ITK_MANUAL_INSTANTIATION
515 # include "itkDisplacementFieldTransform.hxx"
516 #endif
517 
518 #endif // itkDisplacementFieldTransform_h
Pointer
SmartPointer< Self > Pointer
Definition: itkAddImageFilter.h:93
itk::DisplacementFieldTransform::TransformDiffusionTensor
OutputVectorPixelType TransformDiffusionTensor(const InputVectorPixelType &) const
Definition: itkDisplacementFieldTransform.h:257
ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkAddImageFilter.h:94
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::DisplacementFieldTransform::TransformDiffusionTensor
OutputDiffusionTensor3DType TransformDiffusionTensor(const InputDiffusionTensor3DType &) const
Definition: itkDisplacementFieldTransform.h:249
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:105
itk::DisplacementFieldTransform::SetParameters
void SetParameters(const ParametersType &params) override
Definition: itkDisplacementFieldTransform.h:283
itk::DisplacementFieldTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkDisplacementFieldTransform.h:425
itk::Transform< TParametersValueType, VDimension, VDimension >::OutputVnlVectorType
vnl_vector_fixed< TParametersValueType, VOutputDimension > OutputVnlVectorType
Definition: itkTransform.h:157
itk::DisplacementFieldTransform::DirectionType
typename DisplacementFieldType::DirectionType DirectionType
Definition: itkDisplacementFieldTransform.h:173
itk::Transform< TParametersValueType, VDimension, VDimension >::InverseTransformBasePointer
typename InverseTransformBaseType::Pointer InverseTransformBasePointer
Definition: itkTransform.h:167
itk::VectorImage
Templated n-dimensional vector image class.
Definition: itkImageAlgorithm.h:29
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Vector
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
itk::DisplacementFieldTransform::IndexType
typename DisplacementFieldType::IndexType IndexType
Definition: itkDisplacementFieldTransform.h:169
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
itk::DiffusionTensor3D
Represent a diffusion tensor as used in DTI images.
Definition: itkDiffusionTensor3D.h:79
itkImage.h
itk::DisplacementFieldTransform::DisplacementFieldPointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Definition: itkDisplacementFieldTransform.h:163
itk::DisplacementFieldTransform::TransformCovariantVector
OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &) const override
Definition: itkDisplacementFieldTransform.h:274
itk::SmartPointer< Self >
itk::Indent
Control indentation during Print() invocation.
Definition: itkIndent.h:49
itk::ImageVectorOptimizerParametersHelper
Class to hold and manage parameters of type Image<Vector<...>,...>, used in Transforms,...
Definition: itkImageVectorOptimizerParametersHelper.h:37
itk::VectorInterpolateImageFunction
Base class for all vector image interpolators.
Definition: itkVectorInterpolateImageFunction.h:47
itk::DisplacementFieldTransform
Provides local/dense/high-dimensionality transformation via a a displacement field.
Definition: itkDisplacementFieldTransform.h:87
itk::DisplacementFieldTransform::GetNumberOfLocalParameters
NumberOfParametersType GetNumberOfLocalParameters() const override
Definition: itkDisplacementFieldTransform.h:431
itkVectorImage.h
itk::DisplacementFieldTransform::PointType
typename DisplacementFieldType::PointType PointType
Definition: itkDisplacementFieldTransform.h:174
itk::DisplacementFieldTransform::SizeType
typename DisplacementFieldType::SizeType SizeType
Definition: itkDisplacementFieldTransform.h:171
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::DisplacementFieldTransform::TransformCovariantVector
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Definition: itkDisplacementFieldTransform.h:266
itk::point
*par Constraints *The filter requires an image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents
itk::DisplacementFieldTransform::DisplacementFieldConstPointer
typename DisplacementFieldType::ConstPointer DisplacementFieldConstPointer
Definition: itkDisplacementFieldTransform.h:164
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itk::DisplacementFieldTransform::TransformVector
OutputVectorPixelType TransformVector(const InputVectorPixelType &) const override
Definition: itkDisplacementFieldTransform.h:233
itkMatrixOffsetTransformBase.h
itkVectorInterpolateImageFunction.h
itk::DisplacementFieldTransform::RegionType
typename DisplacementFieldType::RegionType RegionType
Definition: itkDisplacementFieldTransform.h:170
itk::Transform< TParametersValueType, VDimension, VDimension >::ScalarType
ParametersValueType ScalarType
Definition: itkTransform.h:127
itk::VariableLengthVector
Represents an array whose length can be defined at run-time.
Definition: itkConstantBoundaryCondition.h:28
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:108
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::DisplacementFieldTransform::ComputeJacobianWithRespectToParameters
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &j) const override
Definition: itkDisplacementFieldTransform.h:333
itk::DisplacementFieldTransform::PixelType
typename DisplacementFieldType::PixelType PixelType
Definition: itkDisplacementFieldTransform.h:175
itk::DisplacementFieldTransform::ComputeJacobianWithRespectToParameters
virtual void ComputeJacobianWithRespectToParameters(const IndexType &, JacobianType &j) const
Definition: itkDisplacementFieldTransform.h:346
itk::Transform< TParametersValueType, VDimension, VDimension >::JacobianPositionType
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
Definition: itkTransform.h:131
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnatomicalOrientation.h:29
itk::DisplacementFieldTransform::SpacingType
typename DisplacementFieldType::SpacingType SpacingType
Definition: itkDisplacementFieldTransform.h:172
itk::Transform< TParametersValueType, VDimension, VDimension >::InverseJacobianPositionType
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
Definition: itkTransform.h:132
itkImageVectorOptimizerParametersHelper.h
itk::Array
Array class with size defined at construction time.
Definition: itkArray.h:47
itk::Point
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:53
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:88
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:83
AddImageFilter
Definition: itkAddImageFilter.h:81
itkTransform.h
itk::DisplacementFieldTransform::TransformVector
OutputVectorType TransformVector(const InputVectorType &) const override
Definition: itkDisplacementFieldTransform.h:225
itk::Array2D
Array2D class representing a 2D array.
Definition: itkArray2D.h:42
itk::TransformCategory::DisplacementField
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::DisplacementFieldTransform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Definition: itkDisplacementFieldTransform.h:240
itk::Transform< TParametersValueType, VDimension, VDimension >::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, VInputDimension > InputVnlVectorType
Definition: itkTransform.h:156