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:
111
115
118
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;
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 {
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 return;
240 }
241
242
249
250 virtual const MatrixType &
251 GetMatrix() const
252 {
253 return m_Matrix;
254 }
255
264 void
266 {
267 m_Offset = offset;
268 this->ComputeTranslation();
269 this->Modified();
270 return;
271 }
272
273
279 const OutputVectorType &
280 GetOffset() const
281 {
282 return m_Offset;
283 }
284
307 void
308 SetCenter(const InputPointType & center)
309 {
310 m_Center = center;
311 this->ComputeOffset();
312 this->Modified();
313 return;
314 }
315
316
323 const InputPointType &
324 GetCenter() const
325 {
326 return m_Center;
327 }
328
335 void
336 SetTranslation(const OutputVectorType & translation)
337 {
338 m_Translation = translation;
339 this->ComputeOffset();
340 this->Modified();
341 return;
342 }
343
344
351 const OutputVectorType &
353 {
354 return m_Translation;
355 }
356
361 void
362 SetParameters(const ParametersType & parameters) override;
363
365 const ParametersType &
366 GetParameters() const override;
367
369 void
371
373 const FixedParametersType &
374 GetFixedParameters() const override;
375
387 void
388 Compose(const Self * other, bool pre = false);
389
397
399 TransformPoint(const InputPointType & point) const override;
400
402
404 TransformVector(const InputVectorType & vect) const override;
405
407 TransformVector(const InputVnlVectorType & vect) const override;
408
410 TransformVector(const InputVectorPixelType & vect) const override;
411
413
416
418 TransformCovariantVector(const InputVectorPixelType & vect) const override;
419
421
424
426 TransformDiffusionTensor3D(const InputVectorPixelType & tensor) const override;
427
431
433 TransformSymmetricSecondRankTensor(const InputVectorPixelType & inputTensor) const override;
434
435
445 void
447
448
452 void
455
459 void
461 InverseJacobianPositionType & jac) const override;
463
482 bool
485
488 GetInverseTransform() const override;
489
495 bool
496 IsLinear() const override
497 {
498 return true;
499 }
500
501protected:
504 const InverseMatrixType &
506
507protected:
515#if !defined(ITK_LEGACY_REMOVE)
516 [[deprecated("Removed unused constructor")]] MatrixOffsetTransformBase(const MatrixType & matrix,
517 const OutputVectorType & offset);
518#endif
519 explicit MatrixOffsetTransformBase(unsigned int paramDims = ParametersDimension);
521
523 ~MatrixOffsetTransformBase() override = default;
524
526 void
527 PrintSelf(std::ostream & os, Indent indent) const override;
528
529 const InverseMatrixType &
531 {
532 return m_InverseMatrix;
533 }
534 void
536 {
537 m_InverseMatrix = matrix;
538 m_InverseMatrixMTime.Modified();
539 }
540 bool
542 {
544 {
545 return true;
546 }
547
548 return false;
549 }
550
551 virtual void
553
554 virtual void
556
557 void
558 SetVarMatrix(const MatrixType & matrix)
559 {
560 m_Matrix = matrix;
561 m_MatrixMTime.Modified();
562 }
563
564 virtual void
566
567 void
569 {
570 m_Translation = translation;
571 }
572
573 virtual void
575
576 void
578 {
579 m_Offset = offset;
580 }
581
582 void
584 {
585 m_Center = center;
586 }
587
588 itkGetConstMacro(Singular, bool);
589
590private:
591 MatrixType m_Matrix{ MatrixType::GetIdentity() }; // Matrix of the transformation
592 OutputVectorType m_Offset{}; // Offset of the transformation
594 mutable bool m_Singular{ false }; // Is m_Inverse singular?
595
598
602}; // class MatrixOffsetTransformBase
603} // namespace itk
604
605#ifndef ITK_MANUAL_INSTANTIATION
606# include "itkMatrixOffsetTransformBase.hxx"
607#endif
608
609#endif /* itkMatrixOffsetTransformBase_h */
OptimizerParameters< FixedParametersValueType > FixedParametersType
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
TParametersValueType ParametersValueType
OptimizerParameters< ParametersValueType > ParametersType
itkOverrideGetNameOfClassMacro(TransformBaseTemplate)
ITK_DISALLOW_COPY_AND_MOVE(TransformBaseTemplate)
static constexpr TransformCategoryEnum Linear
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
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.
VariableLengthVector< TParametersValueType > OutputVectorPixelType
virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType &pnt, InverseJacobianPositionType &jacobian) const
OptimizerParameters< FixedParametersValueType > FixedParametersType
Transform< TParametersValueType, VOutputDimension, VInputDimension > InverseTransformBaseType
TransformBaseTemplateEnums::TransformCategory TransformCategoryEnum
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianPositionType &jacobian) const
VariableLengthVector< TParametersValueType > InputVectorPixelType
virtual OutputVectorType TransformVector(const InputVectorType &) const
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....
*par Constraints *The filter image with at least two dimensions and a vector *length of at least The theory supports extension to scalar but *the implementation of the itk vector classes do not **The template parameter TRealType must be floating point(float or double) or *a user-defined "real" numerical type with arithmetic operations defined *sufficient to compute derivatives. **\par Performance *This filter will automatically multithread if run with *SetUsePrincipleComponents