ITK  5.2.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 InverseTransformBasePointer = typename Superclass::InverseTransformBasePointer;
105 
107  using ScalarType = typename Superclass::ScalarType;
108 
110  using FixedParametersType = typename Superclass::FixedParametersType;
111  using FixedParametersValueType = typename Superclass::FixedParametersValueType;
112  using ParametersType = typename Superclass::ParametersType;
113  using ParametersValueType = typename Superclass::ParametersValueType;
114 
116  using JacobianType = typename Superclass::JacobianType;
117  using JacobianPositionType = typename Superclass::JacobianPositionType;
118  using InverseJacobianPositionType = typename Superclass::InverseJacobianPositionType;
119 
121  using TransformCategoryEnum = typename Superclass::TransformCategoryEnum;
122 
124  using NumberOfParametersType = typename Superclass::NumberOfParametersType;
125 
127  using InputPointType = typename Superclass::InputPointType;
128  using OutputPointType = typename Superclass::OutputPointType;
129 
131  using InputVectorType = typename Superclass::InputVectorType;
132  using OutputVectorType = typename Superclass::OutputVectorType;
133 
134  using InputVectorPixelType = typename Superclass::InputVectorPixelType;
135  using OutputVectorPixelType = typename Superclass::OutputVectorPixelType;
136 
138  using InputCovariantVectorType = typename Superclass::InputCovariantVectorType;
139  using OutputCovariantVectorType = typename Superclass::OutputCovariantVectorType;
140 
142  using InputVnlVectorType = typename Superclass::InputVnlVectorType;
143  using OutputVnlVectorType = typename Superclass::OutputVnlVectorType;
144 
146  using InputDiffusionTensor3DType = typename Superclass::InputDiffusionTensor3DType;
147  using OutputDiffusionTensor3DType = typename Superclass::OutputDiffusionTensor3DType;
148 
152 
154  using DerivativeType = 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::DisplacementFieldTransform::InputVnlVectorType
typename Superclass::InputVnlVectorType InputVnlVectorType
Definition: itkDisplacementFieldTransform.h:142
itk::GTest::TypedefsAndConstructors::Dimension2::DirectionType
ImageBaseType::DirectionType DirectionType
Definition: itkGTestTypedefsAndConstructors.h:52
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::DisplacementFieldTransform::OutputVnlVectorType
typename Superclass::OutputVnlVectorType OutputVnlVectorType
Definition: itkDisplacementFieldTransform.h:143
itk::GTest::TypedefsAndConstructors::Dimension2::SizeType
ImageBaseType::SizeType SizeType
Definition: itkGTestTypedefsAndConstructors.h:49
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::DisplacementFieldTransform::InputDiffusionTensor3DType
typename Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
Definition: itkDisplacementFieldTransform.h:146
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::JacobianType
typename Superclass::JacobianType JacobianType
Definition: itkDisplacementFieldTransform.h:116
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::OutputCovariantVectorType
typename Superclass::OutputCovariantVectorType OutputCovariantVectorType
Definition: itkDisplacementFieldTransform.h:139
itk::DisplacementFieldTransform::DerivativeType
typename Superclass::DerivativeType DerivativeType
Definition: itkDisplacementFieldTransform.h:154
itk::DisplacementFieldTransform::ScalarType
typename Superclass::ScalarType ScalarType
Definition: itkDisplacementFieldTransform.h:107
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::DisplacementFieldTransform::InputVectorType
typename Superclass::InputVectorType InputVectorType
Definition: itkDisplacementFieldTransform.h:131
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
itk::DisplacementFieldTransform::InverseJacobianPositionType
typename Superclass::InverseJacobianPositionType InverseJacobianPositionType
Definition: itkDisplacementFieldTransform.h:118
itkMatrixOffsetTransformBase.h
itkVectorInterpolateImageFunction.h
itk::DisplacementFieldTransform::InputCovariantVectorType
typename Superclass::InputCovariantVectorType InputCovariantVectorType
Definition: itkDisplacementFieldTransform.h:138
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::InputPointType
typename Superclass::InputPointType InputPointType
Definition: itkDisplacementFieldTransform.h:127
itk::DisplacementFieldTransform::DirectionType
typename DisplacementFieldType::DirectionType DirectionType
Definition: itkDisplacementFieldTransform.h:171
itk::DisplacementFieldTransform::SizeType
typename DisplacementFieldType::SizeType SizeType
Definition: itkDisplacementFieldTransform.h:169
itk::DisplacementFieldTransform::InputVectorPixelType
typename Superclass::InputVectorPixelType InputVectorPixelType
Definition: itkDisplacementFieldTransform.h:134
itk::TransformBaseTemplateEnums::TransformCategory
TransformCategory
Definition: itkTransformBase.h:45
itk::DisplacementFieldTransform::m_DirectionTolerance
double m_DirectionTolerance
Definition: itkDisplacementFieldTransform.h:504
itk::DisplacementFieldTransform::OutputPointType
typename Superclass::OutputPointType OutputPointType
Definition: itkDisplacementFieldTransform.h:128
itk::Image::PixelType
TPixel PixelType
Definition: itkImage.h:106
itk::DisplacementFieldTransform::JacobianPositionType
typename Superclass::JacobianPositionType JacobianPositionType
Definition: itkDisplacementFieldTransform.h:117
itk::CovariantVector
A templated class holding a n-Dimensional covariant vector.
Definition: itkCovariantVector.h:70
itk::TransformBaseTemplate::FixedParametersValueType
double FixedParametersValueType
Definition: itkTransformBase.h:83
itk::DisplacementFieldTransform::GetNumberOfLocalParameters
NumberOfParametersType GetNumberOfLocalParameters() const override
Definition: itkDisplacementFieldTransform.h:426
itk::DisplacementFieldTransform::OutputVectorType
typename Superclass::OutputVectorType OutputVectorType
Definition: itkDisplacementFieldTransform.h:132
itk::Image::SpacingType
typename Superclass::SpacingType SpacingType
Definition: itkImage.h:154
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
itk::DisplacementFieldTransform::InverseTransformBasePointer
typename Superclass::InverseTransformBasePointer InverseTransformBasePointer
Definition: itkDisplacementFieldTransform.h:104
itkImageVectorOptimizerParametersHelper.h
itk::DisplacementFieldTransform::OutputDiffusionTensor3DType
typename Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
Definition: itkDisplacementFieldTransform.h:147
itk::TransformBaseTemplate::ParametersValueType
TParametersValueType ParametersValueType
Definition: itkTransformBase.h:81
itk::Array::Size
SizeValueType Size() const
Definition: itkArray.h:131
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:91
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
itk::DisplacementFieldTransform::ComputeJacobianWithRespectToParameters
virtual void ComputeJacobianWithRespectToParameters(const IndexType &, JacobianType &j) const
Definition: itkDisplacementFieldTransform.h:341
itkTransform.h
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::OutputVectorPixelType
typename Superclass::OutputVectorPixelType OutputVectorPixelType
Definition: itkDisplacementFieldTransform.h:135
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