18 #ifndef itkTransform_h
19 #define itkTransform_h
21 #include <type_traits>
27 #include "vnl/vnl_vector_fixed.h"
28 #include "vnl/vnl_matrix_fixed.h"
82 template <
typename TParametersValueType,
unsigned int VInputDimension = 3,
unsigned int VOutputDimension = 3>
99 static constexpr
unsigned int InputSpaceDimension = VInputDimension;
100 static constexpr
unsigned int OutputSpaceDimension = VOutputDimension;
109 return VInputDimension;
116 return VOutputDimension;
121 itkSetMacro(InputSpaceName, std::string);
122 itkGetConstReferenceMacro(InputSpaceName, std::string);
130 itkSetMacro(OutputSpaceName, std::string);
131 itkGetConstReferenceMacro(OutputSpaceName, std::string);
134 using typename Superclass::FixedParametersType;
135 using typename Superclass::FixedParametersValueType;
136 using typename Superclass::ParametersType;
137 using typename Superclass::ParametersValueType;
189 using typename Superclass::NumberOfParametersType;
202 itkExceptionMacro(
"TransformVector(const InputVectorType &)"
203 "is unimplemented for "
211 virtual OutputVectorType
212 TransformVector(
const InputVectorType & vector,
const InputPointType &
point)
const;
215 virtual OutputVnlVectorType
218 itkExceptionMacro(
"TransformVector( const InputVnlVectorType & ) is "
227 virtual OutputVnlVectorType
228 TransformVector(
const InputVnlVectorType & vector,
const InputPointType &
point)
const;
231 virtual OutputVectorPixelType
234 itkExceptionMacro(
"TransformVector( const InputVectorPixelType & ) is "
243 virtual OutputVectorPixelType
244 TransformVector(
const InputVectorPixelType & vector,
const InputPointType &
point)
const;
247 virtual OutputCovariantVectorType
250 itkExceptionMacro(
"TransformCovariantVector( const InputCovariantVectorType & ) is "
260 virtual OutputCovariantVectorType
261 TransformCovariantVector(
const InputCovariantVectorType & vector,
const InputPointType &
point)
const;
265 virtual OutputVectorPixelType
268 itkExceptionMacro(
"TransformCovariantVector(const InputVectorPixelType &)"
269 "is unimplemented for "
278 virtual OutputVectorPixelType
279 TransformCovariantVector(
const InputVectorPixelType & vector,
const InputPointType &
point)
const;
282 virtual OutputDiffusionTensor3DType
285 itkExceptionMacro(
"TransformDiffusionTensor3D( const InputDiffusionTensor3DType & ) is "
295 virtual OutputDiffusionTensor3DType
296 TransformDiffusionTensor3D(
const InputDiffusionTensor3DType & inputTensor,
const InputPointType &
point)
const;
299 virtual OutputVectorPixelType
302 itkExceptionMacro(
"TransformDiffusionTensor( const InputVectorPixelType & ) is "
307 virtual OutputVectorPixelType
308 TransformDiffusionTensor3D(
const InputVectorPixelType & inputTensor,
const InputPointType &
point)
const;
315 virtual OutputSymmetricSecondRankTensorType
316 TransformSymmetricSecondRankTensor(
const InputSymmetricSecondRankTensorType & inputTensor,
317 const InputPointType &
point)
const;
320 virtual OutputSymmetricSecondRankTensorType
323 itkExceptionMacro(
"TransformSymmetricSecondRankTensor( const InputSymmetricSecondRankTensorType & ) is "
329 virtual OutputVectorPixelType
332 itkExceptionMacro(
"TransformSymmetricSecondRankTensor( const InputVectorPixelType & ) is "
343 virtual OutputVectorPixelType
344 TransformSymmetricSecondRankTensor(
const InputVectorPixelType & inputTensor,
const InputPointType &
point)
const;
354 SetParameters(
const ParametersType &)
override = 0;
366 this->SetParameters(p);
374 CopyInParameters(
const ParametersValueType *
const begin,
const ParametersValueType *
const end)
override;
381 CopyInFixedParameters(
const FixedParametersValueType *
const begin,
382 const FixedParametersValueType *
const end)
override;
385 const ParametersType &
393 SetFixedParameters(
const FixedParametersType &)
override = 0;
396 const FixedParametersType &
399 return m_FixedParameters;
410 UpdateTransformParameters(
const DerivativeType & update, ParametersValueType factor = 1.0);
420 virtual NumberOfParametersType
423 return this->GetNumberOfParameters();
427 NumberOfParametersType
430 return this->m_Parameters.Size();
434 virtual NumberOfParametersType
437 return this->m_FixedParameters.Size();
460 virtual InverseTransformBasePointer
468 GetTransformTypeAsString()
const override;
470 using typename Superclass::TransformCategoryEnum;
475 TransformCategoryEnum
478 return Superclass::TransformCategoryEnum::UnknownTransformCategory;
484 return (this->GetTransformCategory() == Superclass::TransformCategoryEnum::Linear);
522 ComputeJacobianWithRespectToParameters(
const InputPointType & itkNotUsed(p),
523 JacobianType & itkNotUsed(jacobian))
const = 0;
532 this->ComputeJacobianWithRespectToParameters(p, jacobian);
545 itkExceptionMacro(
"ComputeJacobianWithRespectToPosition( InputPointType, JacobianType )"
546 " is unimplemented for "
549 itkLegacyMacro(
virtual void ComputeJacobianWithRespectToPosition(
const InputPointType & x, JacobianType & jacobian)
560 ComputeInverseJacobianWithRespectToPosition(
const InputPointType & pnt, InverseJacobianPositionType & jacobian)
const;
561 itkLegacyMacro(
virtual void ComputeInverseJacobianWithRespectToPosition(
const InputPointType & x,
562 JacobianType & jacobian)
const);
574 template <
typename TImage>
575 std::enable_if_t<TImage::ImageDimension == VInputDimension && TImage::ImageDimension == VOutputDimension, void>
576 ApplyToImageMetadata(TImage * image)
const;
577 template <
typename TImage>
578 std::enable_if_t<TImage::ImageDimension == VInputDimension && TImage::ImageDimension == VOutputDimension, void>
581 this->ApplyToImageMetadata(image.
GetPointer());
592 InternalClone()
const override;
597 Transform(NumberOfParametersType numberOfParameters);
598 #if defined(__GNUC__)
606 ~Transform()
override =
default;
611 OutputDiffusionTensor3DType
612 PreservationOfPrincipalDirectionDiffusionTensor3DReorientation(
const InputDiffusionTensor3DType &,
613 const InverseJacobianPositionType &)
const;
616 std::string m_InputSpaceName{};
617 std::string m_OutputSpaceName{};
619 template <
typename TType>
623 std::string rval(
"other");
631 std::string rval(
"float");
639 std::string rval(
"double");
646 #ifndef ITK_MANUAL_INSTANTIATION
647 # include "itkTransform.hxx"