ITK 6.0.0
Insight Toolkit
 
Loading...
Searching...
No Matches
itkMatrixOffsetTransformBase.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 itkMatrixOffsetTransformBase_h
19#define itkMatrixOffsetTransformBase_h
20
21
22#include "itkMacro.h"
23#include "itkMatrix.h"
24#include "itkTransform.h"
25
26#include <iostream>
27
28namespace itk
29{
30
31/* MatrixOrthogonalityTolerance is a utility to
32 * allow setting the tolerance limits used for
33 * checking if a matrix meet the orthogonality
34 * constraints of being a rigid rotation matrix.
35 * The tolerance needs to be different for
36 * matrices of type float vs. double.
37 */
38template <typename T>
40
41template <>
42class ITK_TEMPLATE_EXPORT MatrixOrthogonalityTolerance<double>
43{
44public:
45 static double
47 {
48 return 1e-10;
49 }
50};
51
52template <>
53class ITK_TEMPLATE_EXPORT MatrixOrthogonalityTolerance<float>
54{
55public:
56 static float
58 {
59 return 1e-5f;
60 }
61};
62
104
105template <typename TParametersValueType = double, unsigned int VInputDimension = 3, unsigned int VOutputDimension = 3>
106class ITK_TEMPLATE_EXPORT MatrixOffsetTransformBase
107 : public Transform<TParametersValueType, VInputDimension, VOutputDimension>
108{
109public:
110 ITK_DISALLOW_COPY_AND_MOVE(MatrixOffsetTransformBase);
111
115
118
120 itkOverrideGetNameOfClassMacro(MatrixOffsetTransformBase);
121
123 itkNewMacro(Self);
124
126 static constexpr unsigned int InputSpaceDimension = VInputDimension;
127 static constexpr unsigned int OutputSpaceDimension = VOutputDimension;
128 static constexpr unsigned int ParametersDimension = VOutputDimension * (VInputDimension + 1);
131 using typename Superclass::FixedParametersType;
145 using typename Superclass::ScalarType;
146
151
155
158
166
168
170 using InputVnlVectorType = vnl_vector_fixed<TParametersValueType, Self::InputSpaceDimension>;
171 using OutputVnlVectorType = vnl_vector_fixed<TParametersValueType, Self::OutputSpaceDimension>;
172
178
182
185
187
190
192
194
198 using InverseTransformBasePointer = typename InverseTransformBaseType::Pointer;
199
203 friend class MatrixOffsetTransformBase<TParametersValueType, VOutputDimension, VInputDimension>;
204
208 virtual void
210
215 GetTransformCategory() const override
216 {
217 return Self::TransformCategoryEnum::Linear;
218 }
219
231 virtual void
232 SetMatrix(const MatrixType & matrix)
233 {
234 m_Matrix = matrix;
235 this->ComputeOffset();
237 m_MatrixMTime.Modified();
238 this->Modified();
239 }
240
247
248 virtual const MatrixType &
249 GetMatrix() const
250 {
251 return m_Matrix;
252 }
253
262 void
264 {
265 m_Offset = offset;
266 this->ComputeTranslation();
267 this->Modified();
268 }
269
275 const OutputVectorType &
276 GetOffset() const
277 {
278 return m_Offset;
279 }
280
303 void
304 SetCenter(const InputPointType & center)
305 {
306 m_Center = center;
307 this->ComputeOffset();
308 this->Modified();
309 }
310
317 const InputPointType &
318 GetCenter() const
319 {
320 return m_Center;
321 }
322
329 void
330 SetTranslation(const OutputVectorType & translation)
331 {
332 m_Translation = translation;
333 this->ComputeOffset();
334 this->Modified();
335 }
336
343 const OutputVectorType &
345 {
346 return m_Translation;
347 }
348
353 void
354 SetParameters(const ParametersType & parameters) override;
355
357 const ParametersType &
358 GetParameters() const override;
359
361 void
363
365 const FixedParametersType &
366 GetFixedParameters() const override;
367
379 void
380 Compose(const Self * other, bool pre = false);
381
389
391 TransformPoint(const InputPointType & point) const override;
392
394
396 TransformVector(const InputVectorType & vect) const override;
397
399 TransformVector(const InputVnlVectorType & vect) const override;
400
402 TransformVector(const InputVectorPixelType & vect) const override;
403
405
408
410 TransformCovariantVector(const InputVectorPixelType & vect) const override;
411
413
416
418 TransformDiffusionTensor3D(const InputVectorPixelType & tensor) const override;
419
423
425 TransformSymmetricSecondRankTensor(const InputVectorPixelType & inputTensor) const override;
426
427
437 void
439
440
444 void
447
451 void
453 InverseJacobianPositionType & jac) const override;
455
474 bool
476
479 GetInverseTransform() const override;
480
486 bool
487 IsLinear() const override
488 {
489 return true;
490 }
491
492protected:
495 const InverseMatrixType &
497
498protected:
507#if !defined(ITK_LEGACY_REMOVE)
508 [[deprecated("Removed unused constructor")]] MatrixOffsetTransformBase(const MatrixType & matrix,
509 const OutputVectorType & offset);
510#endif
511 explicit MatrixOffsetTransformBase(unsigned int paramDims = ParametersDimension);
513
515 ~MatrixOffsetTransformBase() override = default;
516
518 void
519 PrintSelf(std::ostream & os, Indent indent) const override;
520
521 const InverseMatrixType &
523 {
524 return m_InverseMatrix;
525 }
526 void
528 {
529 m_InverseMatrix = matrix;
530 m_InverseMatrixMTime.Modified();
531 }
532 bool
534 {
536 {
537 return true;
538 }
539
540 return false;
541 }
542
543 virtual void
545
546 virtual void
548
549 void
550 SetVarMatrix(const MatrixType & matrix)
551 {
552 m_Matrix = matrix;
553 m_MatrixMTime.Modified();
554 }
555
556 virtual void
558
559 void
561 {
562 m_Translation = translation;
563 }
564
565 virtual void
567
568 void
570 {
571 m_Offset = offset;
572 }
573
574 void
576 {
577 m_Center = center;
578 }
579
580 itkGetConstMacro(Singular, bool);
581
582private:
583 MatrixType m_Matrix{ MatrixType::GetIdentity() }; // Matrix of the transformation
584 OutputVectorType m_Offset{}; // Offset of the transformation
586 mutable bool m_Singular{ false }; // Is m_Inverse singular?
587
590
594}; // class MatrixOffsetTransformBase
595} // namespace itk
596
597#ifndef ITK_MANUAL_INSTANTIATION
598# include "itkMatrixOffsetTransformBase.hxx"
599#endif
600
601#endif /* itkMatrixOffsetTransformBase_h */
A templated class holding a n-Dimensional covariant vector.
Control indentation during Print() invocation.
Definition itkIndent.h:50
vnl_vector_fixed< TParametersValueType, Self::InputSpaceDimension > InputVnlVectorType
const OutputVectorType & GetTranslation() const
SymmetricSecondRankTensor< TParametersValueType, VInputDimension > InputSymmetricSecondRankTensorType
void PrintSelf(std::ostream &os, Indent indent) const override
void ComputeJacobianWithRespectToParameters(const InputPointType &p, JacobianType &jacobian) const override
void SetParameters(const ParametersType &parameters) override
OutputVectorPixelType TransformSymmetricSecondRankTensor(const InputVectorPixelType &inputTensor) const override
void SetVarMatrix(const MatrixType &matrix)
const OutputVectorType & GetOffset() const
virtual const MatrixType & GetMatrix() const
void SetVarCenter(const InputPointType &center)
vnl_matrix_fixed< ParametersValueType, VOutputDimension, VInputDimension > JacobianPositionType
InverseTransformBasePointer GetInverseTransform() const override
void SetVarInverseMatrix(const InverseMatrixType &matrix) const
void SetVarOffset(const OutputVectorType &offset)
OutputVectorType TransformVector(const InputVectorType &vect) const override
MatrixOffsetTransformBase< TParametersValueType, VOutputDimension, VInputDimension > InverseTransformType
void SetTranslation(const OutputVectorType &translation)
void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianPositionType &jac) const override
vnl_vector_fixed< TParametersValueType, Self::OutputSpaceDimension > OutputVnlVectorType
const InverseMatrixType & GetVarInverseMatrix() const
Matrix< TParametersValueType, Self::InputSpaceDimension, Self::OutputSpaceDimension > InverseMatrixType
const ParametersType & GetParameters() const override
CovariantVector< TParametersValueType, Self::InputSpaceDimension > InputCovariantVectorType
~MatrixOffsetTransformBase() override=default
Transform< TParametersValueType, VInputDimension, VOutputDimension > Superclass
void SetCenter(const InputPointType &center)
const InverseMatrixType & GetInverseMatrix() const
CovariantVector< TParametersValueType, InputDiffusionTensor3DType::Dimension > InputTensorEigenVectorType
OutputVectorPixelType TransformDiffusionTensor3D(const InputVectorPixelType &tensor) const override
CovariantVector< TParametersValueType, Self::OutputSpaceDimension > OutputCovariantVectorType
bool GetInverse(InverseTransformType *inverse) const
const FixedParametersType & GetFixedParameters() const override
OutputPointType TransformPoint(const InputPointType &point) const override
TransformCategoryEnum GetTransformCategory() const override
OutputVnlVectorType TransformVector(const InputVnlVectorType &vect) const override
MatrixOffsetTransformBase(unsigned int paramDims=ParametersDimension)
void ComputeInverseJacobianWithRespectToPosition(const InputPointType &x, InverseJacobianPositionType &jac) const override
OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType &vect) const override
void Compose(const Self *other, bool pre=false)
void SetFixedParameters(const FixedParametersType &) override
OutputVectorPixelType TransformVector(const InputVectorPixelType &vect) const override
void SetOffset(const OutputVectorType &offset)
OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &tensor) const override
const InputPointType & GetCenter() const
virtual void SetMatrix(const MatrixType &matrix)
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vec) const override
OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor) const override
SymmetricSecondRankTensor< TParametersValueType, VOutputDimension > OutputSymmetricSecondRankTensorType
Matrix< TParametersValueType, Self::OutputSpaceDimension, Self::InputSpaceDimension > MatrixType
void SetVarTranslation(const OutputVectorType &translation)
vnl_matrix_fixed< ParametersValueType, VInputDimension, VOutputDimension > InverseJacobianPositionType
A templated class holding a M x N size Matrix.
Definition itkMatrix.h:53
virtual void Modified() const
A templated class holding a geometric point in n-Dimensional space.
Definition itkPoint.h:54
Implements transparent reference counting.
Generate a unique, increasing time value.
OptimizerParameters< ParametersValueType > ParametersType
TParametersValueType ParametersValueType
OptimizerParameters< FixedParametersValueType > FixedParametersType
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
VariableLengthVector< TParametersValueType > OutputVectorPixelType
virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType &pnt, InverseJacobianPositionType &jacobian) const
Transform< TParametersValueType, VOutputDimension, VInputDimension > InverseTransformBaseType
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianPositionType &jacobian) const
OptimizerParameters< FixedParametersValueType > FixedParametersType
VariableLengthVector< TParametersValueType > InputVectorPixelType
virtual OutputVectorType TransformVector(const InputVectorType &) const
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
DiffusionTensor3D< TParametersValueType > OutputDiffusionTensor3DType
virtual OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &inputTensor, const InputPointType &point) const
virtual OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &tensor) const
virtual OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &) const
A templated class holding a n-Dimensional vector.
Definition itkVector.h:63
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....