ITK  5.1.0
Insight Toolkit
itkDisplacementFieldTransform.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 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_ASSIGN(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 * inverseDisplacementField);
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 & thisPoint) 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 & x, JacobianPositionType & j) const override;
352  using Superclass::ComputeJacobianWithRespectToPosition;
353 
358  void
359  ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, InverseJacobianPositionType & j) const override;
360  using Superclass::ComputeInverseJacobianWithRespectToPosition;
361 
366  virtual void
367  ComputeJacobianWithRespectToPosition(const IndexType & x, JacobianPositionType & j) const;
368 
380  virtual void
381  GetInverseJacobianOfForwardFieldWithRespectToPosition(const InputPointType & point,
382  JacobianPositionType & jacobian,
383  bool useSVD = false) const;
384 
396  virtual void
397  GetInverseJacobianOfForwardFieldWithRespectToPosition(const IndexType & index,
398  JacobianPositionType & jacobian,
399  bool useSVD = false) const;
400 
401  void
402  UpdateTransformParameters(const DerivativeType & update, ScalarType factor = 1.0) override;
403 
406  bool
407  GetInverse(Self * inverse) const;
408 
411  InverseTransformBasePointer
412  GetInverseTransform() const override;
413 
414  virtual void
415  SetIdentity();
416 
418  TransformCategoryEnum
419  GetTransformCategory() const override
420  {
421  return Self::TransformCategoryEnum::DisplacementField;
422  }
423 
424  NumberOfParametersType
425  GetNumberOfLocalParameters() const override
426  {
427  return Dimension;
428  }
429 
437  itkSetMacro(CoordinateTolerance, double);
438  itkGetConstMacro(CoordinateTolerance, double);
440 
448  itkSetMacro(DirectionTolerance, double);
449  itkGetConstMacro(DirectionTolerance, double);
451 
452 protected:
454  ~DisplacementFieldTransform() override = default;
455  void
456  PrintSelf(std::ostream & os, Indent indent) const override;
457 
461 
465 
468  ModifiedTimeType m_DisplacementFieldSetTime{ 0 };
469 
473 
474 private:
483  virtual void
484  ComputeJacobianWithRespectToPositionInternal(const IndexType & index,
485  JacobianPositionType & jacobian,
486  bool doInverseJacobian) const;
487 
492  virtual void
493  VerifyFixedParametersInformation();
494 
499  virtual void
500  SetFixedParametersFromDisplacementField() const;
501 
504 };
505 
506 } // end namespace itk
507 
508 #ifndef ITK_MANUAL_INSTANTIATION
509 # include "itkDisplacementFieldTransform.hxx"
510 #endif
511 
512 #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:34
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:460
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:46
itk::DisplacementFieldTransform::m_CoordinateTolerance
double m_CoordinateTolerance
Definition: itkDisplacementFieldTransform.h:502
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:463
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:459
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:464
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::DisplacementFieldTransform::m_DirectionTolerance
double m_DirectionTolerance
Definition: itkDisplacementFieldTransform.h:503
itk::TransformBaseTemplate::TransformCategoryEnum
TransformCategoryEnum
Definition: itkTransformBase.h:126
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:68
itk::TransformBaseTemplate::FixedParametersValueType
double FixedParametersValueType
Definition: itkTransformBase.h:60
itk::DisplacementFieldTransform::GetNumberOfLocalParameters
NumberOfParametersType GetNumberOfLocalParameters() const override
Definition: itkDisplacementFieldTransform.h:425
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: itkArray.h:26
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:58
itk::Array::Size
SizeValueType Size() const
Definition: itkArray.h:124
itk::Image
Templated n-dimensional image class.
Definition: itkImage.h:86
itk::TransformBaseTemplate::NumberOfParametersType
IdentifierType NumberOfParametersType
Definition: itkTransformBase.h:68
itk::Transform
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:81
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:472
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:419