ITK  5.3.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  * 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 itkDisplacementFieldTransform_h
19 #define itkDisplacementFieldTransform_h
20 
21 #include "itkTransform.h"
22 
23 #include "itkImage.h"
27 
28 namespace itk
29 {
30 
85 template <typename TParametersValueType, unsigned int NDimensions>
86 class ITK_TEMPLATE_EXPORT DisplacementFieldTransform : public Transform<TParametersValueType, NDimensions, NDimensions>
87 {
88 public:
89  ITK_DISALLOW_COPY_AND_MOVE(DisplacementFieldTransform);
90 
96 
99 
101  itkNewMacro(Self);
102 
104  using typename Superclass::InverseTransformBasePointer;
105 
107  using typename Superclass::ScalarType;
108 
110  using typename Superclass::FixedParametersType;
111  using typename Superclass::FixedParametersValueType;
112  using typename Superclass::ParametersType;
113  using typename Superclass::ParametersValueType;
114 
116  using typename Superclass::JacobianType;
117  using typename Superclass::JacobianPositionType;
118  using typename Superclass::InverseJacobianPositionType;
119 
121  using typename Superclass::TransformCategoryEnum;
122 
124  using typename Superclass::NumberOfParametersType;
125 
127  using typename Superclass::InputPointType;
128  using typename Superclass::OutputPointType;
129 
131  using typename Superclass::InputVectorType;
132  using typename Superclass::OutputVectorType;
133 
134  using typename Superclass::InputVectorPixelType;
135  using typename Superclass::OutputVectorPixelType;
136 
138  using typename Superclass::InputCovariantVectorType;
139  using typename Superclass::OutputCovariantVectorType;
140 
142  using typename Superclass::InputVnlVectorType;
143  using typename Superclass::OutputVnlVectorType;
144 
146  using typename Superclass::InputDiffusionTensor3DType;
147  using typename Superclass::OutputDiffusionTensor3DType;
148 
152 
154  using typename Superclass::DerivativeType;
155 
157  static constexpr unsigned int Dimension = NDimensions;
158 
163 
165 
174 
178 
183  virtual void
184  SetDisplacementField(DisplacementFieldType * field);
185  itkGetModifiableObjectMacro(DisplacementField, DisplacementFieldType);
187 
190  virtual void
191  SetInverseDisplacementField(DisplacementFieldType * inverseField);
192  itkGetModifiableObjectMacro(InverseDisplacementField, DisplacementFieldType);
194 
197  virtual void
198  SetInterpolator(InterpolatorType * interpolator);
199  itkGetModifiableObjectMacro(Interpolator, InterpolatorType);
201 
204  virtual void
205  SetInverseInterpolator(InterpolatorType * interpolator);
206  itkGetModifiableObjectMacro(InverseInterpolator, InterpolatorType);
208 
210  itkGetConstReferenceMacro(DisplacementFieldSetTime, ModifiedTimeType);
211 
215  TransformPoint(const InputPointType & inputPoint) const override;
216 
218  using Superclass::TransformVector;
220  TransformVector(const InputVectorType &) const override
221  {
222  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
223  "TransformVector(Vector,Point)");
224  }
226 
227  OutputVectorPixelType
228  TransformVector(const InputVectorPixelType &) const override
229  {
230  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
231  "TransformVector(Vector,Point)");
232  }
233 
234  OutputVnlVectorType
235  TransformVector(const InputVnlVectorType &) const override
236  {
237  itkExceptionMacro("TransformVector(Vector) unimplemented, use "
238  "TransformVector(Vector,Point)");
239  }
240 
242  using Superclass::TransformDiffusionTensor3D;
243  OutputDiffusionTensor3DType
245  {
246  itkExceptionMacro("TransformDiffusionTensor(Tensor) unimplemented, use "
247  "TransformDiffusionTensor(Tensor,Point)");
248  }
250 
251  OutputVectorPixelType
253  {
254  itkExceptionMacro("TransformDiffusionTensor(Tensor) unimplemented, use "
255  "TransformDiffusionTensor(Tensor,Point)");
256  }
257 
259  using Superclass::TransformCovariantVector;
260  OutputCovariantVectorType
262  {
263  itkExceptionMacro("TransformCovariantVector(CovariantVector) "
264  "unimplemented, use TransformCovariantVector(CovariantVector,Point)");
265  }
267 
268  OutputVectorPixelType
270  {
271  itkExceptionMacro("TransformCovariantVector(CovariantVector) "
272  "unimplemented, use TransformCovariantVector(CovariantVector,Point)");
273  }
274 
277  void
278  SetParameters(const ParametersType & params) override
279  {
280  if (&(this->m_Parameters) != &params)
281  {
282  if (params.Size() != this->m_Parameters.Size())
283  {
284  itkExceptionMacro("Input parameters size (" << params.Size() << ") does not match internal size ("
285  << this->m_Parameters.Size() << ").");
286  }
287  // Copy into existing object
288  this->m_Parameters = params;
289  this->Modified();
290  }
291  }
293 
303  void
304  SetFixedParameters(const FixedParametersType &) override;
305 
327  void
329  {
330  j = this->m_IdentityJacobian;
331  }
333 
340  virtual void
342  {
343  j = this->m_IdentityJacobian;
344  }
345 
350  void
351  ComputeJacobianWithRespectToPosition(const InputPointType & point, JacobianPositionType & jacobian) const override;
352  using Superclass::ComputeJacobianWithRespectToPosition;
353 
358  void
359  ComputeInverseJacobianWithRespectToPosition(const InputPointType & point,
360  InverseJacobianPositionType & jacobian) const override;
361  using Superclass::ComputeInverseJacobianWithRespectToPosition;
362 
367  virtual void
368  ComputeJacobianWithRespectToPosition(const IndexType & index, JacobianPositionType & jacobian) const;
369 
381  virtual void
382  GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
383  JacobianPositionType & jacobian,
384  bool useSVD = false) const;
385 
397  virtual void
398  GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index,
399  JacobianPositionType & jacobian,
400  bool useSVD = false) const;
401 
402  void
403  UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
404 
407  bool
408  GetInverse(Self * inverse) const;
409 
412  InverseTransformBasePointer
413  GetInverseTransform() const override;
414 
415  virtual void
416  SetIdentity();
417 
419  TransformCategoryEnum
420  GetTransformCategory() const override
421  {
422  return Self::TransformCategoryEnum::DisplacementField;
423  }
424 
425  NumberOfParametersType
426  GetNumberOfLocalParameters() const override
427  {
428  return Dimension;
429  }
430 
438  itkSetMacro(CoordinateTolerance, double);
439  itkGetConstMacro(CoordinateTolerance, double);
441 
449  itkSetMacro(DirectionTolerance, double);
450  itkGetConstMacro(DirectionTolerance, double);
452 
453 protected:
455  ~DisplacementFieldTransform() override = default;
456  void
457  PrintSelf(std::ostream & os, Indent indent) const override;
458 
462 
466 
469  ModifiedTimeType m_DisplacementFieldSetTime{ 0 };
470 
474 
475 private:
484  virtual void
485  ComputeJacobianWithRespectToPositionInternal(const IndexType & index,
486  JacobianPositionType & jacobian,
487  bool doInverseJacobian) const;
488 
493  virtual void
494  VerifyFixedParametersInformation();
495 
500  virtual void
501  SetFixedParametersFromDisplacementField() const;
502 
505 };
506 
507 } // end namespace itk
508 
509 #ifndef ITK_MANUAL_INSTANTIATION
510 # include "itkDisplacementFieldTransform.hxx"
511 #endif
512 
513 #endif // itkDisplacementFieldTransform_h
itk::DisplacementFieldTransform::IndexType
typename DisplacementFieldType::IndexType IndexType
Definition: itkDisplacementFieldTransform.h:167
itk::OptimizerParameters
Class to hold and manage different parameter types used during optimization.
Definition: itkOptimizerParameters.h:36
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
itk::Transform< TParametersValueType, NDimensions, NDimensions >::JacobianPositionType
vnl_matrix_fixed< ParametersValueType, NOutputDimensions, NInputDimensions > JacobianPositionType
Definition: itkTransform.h:131
itk::ModifiedTimeType
SizeValueType ModifiedTimeType
Definition: itkIntTypes.h:102
itk::DisplacementFieldTransform::m_InverseDisplacementField
DisplacementFieldType::Pointer m_InverseDisplacementField
Definition: itkDisplacementFieldTransform.h:461
itk::GTest::TypedefsAndConstructors::Dimension2::PointType
ImageBaseType::PointType PointType
Definition: itkGTestTypedefsAndConstructors.h:51
itk::Vector< SpacingValueType, VImageDimension >
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::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::m_CoordinateTolerance
double m_CoordinateTolerance
Definition: itkDisplacementFieldTransform.h:503
itk::DisplacementFieldTransform::TransformCovariantVector
OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &) const override
Definition: itkDisplacementFieldTransform.h:269
itk::DisplacementFieldTransform::m_Interpolator
InterpolatorType::Pointer m_Interpolator
Definition: itkDisplacementFieldTransform.h:464
itk::DisplacementFieldTransform
Provides local/dense/high-dimensionality transformation via a a displacement field.
Definition: itkDisplacementFieldTransform.h:86
itk::DisplacementFieldTransform::m_DisplacementField
DisplacementFieldType::Pointer m_DisplacementField
Definition: itkDisplacementFieldTransform.h:460
itk::DisplacementFieldTransform::SpacingType
typename DisplacementFieldType::SpacingType SpacingType
Definition: itkDisplacementFieldTransform.h:170
itk::GTest::TypedefsAndConstructors::Dimension2::IndexType
ImageBaseType::IndexType IndexType
Definition: itkGTestTypedefsAndConstructors.h:50
itk::LightObject
Light weight base class for most itk classes.
Definition: itkLightObject.h:59
itk::DisplacementFieldTransform::SetParameters
void SetParameters(const ParametersType &params) override
Definition: itkDisplacementFieldTransform.h:278
itk::DisplacementFieldTransform::TransformVector
OutputVectorPixelType TransformVector(const InputVectorPixelType &) const override
Definition: itkDisplacementFieldTransform.h:228
itk::DisplacementFieldTransform::DisplacementFieldConstPointer
typename DisplacementFieldType::ConstPointer DisplacementFieldConstPointer
Definition: itkDisplacementFieldTransform.h:162
itk::DisplacementFieldTransform::TransformVector
OutputVnlVectorType TransformVector(const InputVnlVectorType &) const override
Definition: itkDisplacementFieldTransform.h:235
itk::GTest::TypedefsAndConstructors::Dimension2::RegionType
ImageBaseType::RegionType RegionType
Definition: itkGTestTypedefsAndConstructors.h:54
itkMatrixOffsetTransformBase.h
itkVectorInterpolateImageFunction.h
itk::DisplacementFieldTransform::m_InverseInterpolator
InterpolatorType::Pointer m_InverseInterpolator
Definition: itkDisplacementFieldTransform.h:465
itk::DisplacementFieldTransform::RegionType
typename DisplacementFieldType::RegionType RegionType
Definition: itkDisplacementFieldTransform.h:168
itk::DisplacementFieldTransform::DirectionType
typename DisplacementFieldType::DirectionType DirectionType
Definition: itkDisplacementFieldTransform.h:171
itk::DisplacementFieldTransform::SizeType
typename DisplacementFieldType::SizeType SizeType
Definition: itkDisplacementFieldTransform.h:169
itk::VariableLengthVector
Represents an array whose length can be defined at run-time.
Definition: itkConstantBoundaryCondition.h:28
itk::DisplacementFieldTransform::m_DirectionTolerance
double m_DirectionTolerance
Definition: itkDisplacementFieldTransform.h:504
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::Transform< TParametersValueType, NDimensions, NDimensions >::InputVnlVectorType
vnl_vector_fixed< TParametersValueType, NInputDimensions > InputVnlVectorType
Definition: itkTransform.h:156
itk::DisplacementFieldTransform::GetNumberOfLocalParameters
NumberOfParametersType GetNumberOfLocalParameters() const override
Definition: itkDisplacementFieldTransform.h:426
itk
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
Definition: itkAnnulusOperator.h:24
itk::DisplacementFieldTransform::TransformVector
OutputVectorType TransformVector(const InputVectorType &) const override
Definition: itkDisplacementFieldTransform.h:220
itkImageVectorOptimizerParametersHelper.h
itk::Array::Size
SizeValueType Size() const
Definition: itkArray.h:128
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
itk::DisplacementFieldTransform::ComputeJacobianWithRespectToParameters
virtual void ComputeJacobianWithRespectToParameters(const IndexType &, JacobianType &j) const
Definition: itkDisplacementFieldTransform.h:341
itkTransform.h
itk::Array2D
Array2D class representing a 2D array with size defined at construction time.
Definition: itkArray2D.h:45
itk::DisplacementFieldTransform::PixelType
typename DisplacementFieldType::PixelType PixelType
Definition: itkDisplacementFieldTransform.h:173
itk::DisplacementFieldTransform::PointType
typename DisplacementFieldType::PointType PointType
Definition: itkDisplacementFieldTransform.h:172
itk::DisplacementFieldTransform::m_IdentityJacobian
JacobianType m_IdentityJacobian
Definition: itkDisplacementFieldTransform.h:473
itk::DisplacementFieldTransform::TransformDiffusionTensor
OutputVectorPixelType TransformDiffusionTensor(const InputVectorPixelType &) const
Definition: itkDisplacementFieldTransform.h:252
itk::GTest::TypedefsAndConstructors::Dimension2::Dimension
constexpr unsigned int Dimension
Definition: itkGTestTypedefsAndConstructors.h:44
itk::DisplacementFieldTransform::ComputeJacobianWithRespectToParameters
void ComputeJacobianWithRespectToParameters(const InputPointType &, JacobianType &j) const override
Definition: itkDisplacementFieldTransform.h:328
itk::DisplacementFieldTransform::TransformCovariantVector
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const override
Definition: itkDisplacementFieldTransform.h:261
itk::DisplacementFieldTransform::TransformDiffusionTensor
OutputDiffusionTensor3DType TransformDiffusionTensor(const InputDiffusionTensor3DType &) const
Definition: itkDisplacementFieldTransform.h:244
itk::DisplacementFieldTransform::DisplacementFieldPointer
typename DisplacementFieldType::Pointer DisplacementFieldPointer
Definition: itkDisplacementFieldTransform.h:161
itk::DisplacementFieldTransform::GetTransformCategory
TransformCategoryEnum GetTransformCategory() const override
Definition: itkDisplacementFieldTransform.h:420