ITK  4.8.0
Insight Segmentation and Registration Toolkit
itkMatrixOffsetTransformBase.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 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 
28 namespace itk
29 {
71 template<typename TParametersValueType=double,
72  unsigned int NInputDimensions = 3,
73  unsigned int NOutputDimensions = 3>
75  public Transform<TParametersValueType, NInputDimensions, NOutputDimensions>
76 {
77 public:
80  typedef Transform<TParametersValueType,
81  NInputDimensions,
82  NOutputDimensions> Superclass;
83 
86 
88  itkTypeMacro(MatrixOffsetTransformBase, Transform);
89 
91  itkNewMacro(Self);
92 
94  itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
95  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
96  itkStaticConstMacro( ParametersDimension, unsigned int,
97  NOutputDimensions * ( NInputDimensions + 1 ) );
99 
105 
108 
111 
114 
116  typedef Vector<TParametersValueType,
117  itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
118  typedef Vector<TParametersValueType,
119  itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
122 
124  typedef CovariantVector<TParametersValueType,
125  itkGetStaticConstMacro(InputSpaceDimension)>
127  typedef CovariantVector<TParametersValueType,
128  itkGetStaticConstMacro(OutputSpaceDimension)>
131 
134 
140 
146 
149 
151  typedef vnl_vector_fixed<TParametersValueType,
152  itkGetStaticConstMacro(InputSpaceDimension)>
154  typedef vnl_vector_fixed<TParametersValueType,
155  itkGetStaticConstMacro(OutputSpaceDimension)>
158 
160  typedef Point<TParametersValueType,
161  itkGetStaticConstMacro(InputSpaceDimension)>
164  typedef Point<TParametersValueType,
165  itkGetStaticConstMacro(OutputSpaceDimension)>
169 
171  typedef Matrix<TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension),
172  itkGetStaticConstMacro(InputSpaceDimension)>
176 
178  typedef Matrix<TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension),
179  itkGetStaticConstMacro(OutputSpaceDimension)>
181 
183 
186 
188 
190 
195 
199  virtual void SetIdentity();
200 
204  virtual TransformCategoryType GetTransformCategory() const ITK_OVERRIDE
205  {
206  return Self::Linear;
207  }
208 
220  virtual void SetMatrix(const MatrixType & matrix)
221  {
222  m_Matrix = matrix; this->ComputeOffset();
223  this->ComputeMatrixParameters();
224  m_MatrixMTime.Modified(); this->Modified(); return;
225  }
227 
235  virtual const MatrixType & GetMatrix() const
236  {
237  return m_Matrix;
238  }
239 
248  void SetOffset(const OutputVectorType & offset)
249  {
250  m_Offset = offset; this->ComputeTranslation();
251  this->Modified(); return;
252  }
254 
260  const OutputVectorType & GetOffset() const
261  {
262  return m_Offset;
263  }
264 
287  void SetCenter(const InputPointType & center)
288  {
289  m_Center = center; this->ComputeOffset();
290  this->Modified(); return;
291  }
293 
300  const InputPointType & GetCenter() const
301  {
302  return m_Center;
303  }
304 
311  void SetTranslation(const OutputVectorType & translation)
312  {
313  m_Translation = translation; this->ComputeOffset();
314  this->Modified(); return;
315  }
317 
325  {
326  return m_Translation;
327  }
328 
333  void SetParameters(const ParametersType & parameters) ITK_OVERRIDE;
334 
336  const ParametersType & GetParameters() const ITK_OVERRIDE;
337 
339  virtual void SetFixedParameters(const FixedParametersType &) ITK_OVERRIDE;
340 
342  virtual const FixedParametersType & GetFixedParameters() const ITK_OVERRIDE;
343 
355  void Compose(const Self *other, bool pre = 0);
356 
365  OutputPointType TransformPoint(const InputPointType & point) const ITK_OVERRIDE;
366 
368 
369  OutputVectorType TransformVector(const InputVectorType & vector) const ITK_OVERRIDE;
370 
371  OutputVnlVectorType TransformVector(const InputVnlVectorType & vector) const ITK_OVERRIDE;
372 
373  OutputVectorPixelType TransformVector(const InputVectorPixelType & vector) const ITK_OVERRIDE;
374 
376 
377  OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType & vector) const ITK_OVERRIDE;
378 
379  OutputVectorPixelType TransformCovariantVector(const InputVectorPixelType & vector) const ITK_OVERRIDE;
380 
382 
383  OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType & tensor) const ITK_OVERRIDE;
384 
385  OutputVectorPixelType TransformDiffusionTensor3D(const InputVectorPixelType & tensor ) const ITK_OVERRIDE;
386 
388  OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor( const InputSymmetricSecondRankTensorType & tensor ) const ITK_OVERRIDE;
389 
390  OutputVectorPixelType TransformSymmetricSecondRankTensor( const InputVectorPixelType & tensor ) const ITK_OVERRIDE;
391 
401  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & x, JacobianType & j) const ITK_OVERRIDE;
402 
406  virtual void ComputeJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const ITK_OVERRIDE;
407 
411  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType & x, JacobianType & jac) const ITK_OVERRIDE;
412 
431  bool GetInverse(Self *inverse) const;
433 
435  virtual InverseTransformBasePointer GetInverseTransform() const ITK_OVERRIDE;
436 
442  virtual bool IsLinear() const ITK_OVERRIDE
443  {
444  return true;
445  }
446 
447 #if !defined(ITK_LEGACY_REMOVE)
448 
449 public:
450 #else
451 
452 protected:
453 #endif
454 
456  const InverseMatrixType & GetInverseMatrix() const;
457 
458 protected:
466  MatrixOffsetTransformBase(const MatrixType & matrix, const OutputVectorType & offset);
467  MatrixOffsetTransformBase(unsigned int paramDims);
470 
472  virtual ~MatrixOffsetTransformBase();
473 
475  virtual void PrintSelf(std::ostream & s, Indent indent) const ITK_OVERRIDE;
476 
478  {
479  return m_InverseMatrix;
480  }
481  void SetVarInverseMatrix(const InverseMatrixType & matrix) const
482  {
484  }
485  bool InverseMatrixIsOld() const
486  {
488  {
489  return true;
490  }
491  else
492  {
493  return false;
494  }
495  }
496 
497  virtual void ComputeMatrixParameters();
498 
499  virtual void ComputeMatrix();
500 
501  void SetVarMatrix(const MatrixType & matrix)
502  {
503  m_Matrix = matrix; m_MatrixMTime.Modified();
504  }
505 
506  virtual void ComputeTranslation();
507 
508  void SetVarTranslation(const OutputVectorType & translation)
509  {
510  m_Translation = translation;
511  }
512 
513  virtual void ComputeOffset();
514 
515  void SetVarOffset(const OutputVectorType & offset)
516  {
517  m_Offset = offset;
518  }
519 
520  void SetVarCenter(const InputPointType & center)
521  {
522  m_Center = center;
523  }
524 
525 private:
526 
527  MatrixOffsetTransformBase(const Self & other);
528  const Self & operator=(const Self &);
529 
530  MatrixType m_Matrix; // Matrix of the transformation
531  OutputVectorType m_Offset; // Offset of the transformation
532  mutable InverseMatrixType m_InverseMatrix; // Inverse of the matrix
533  mutable bool m_Singular; // Is m_Inverse singular?
534 
537 
541 }; // class MatrixOffsetTransformBase
542 } // namespace itk
543 
544 #ifndef ITK_MANUAL_INSTANTIATION
545 #include "itkMatrixOffsetTransformBase.hxx"
546 #endif
547 
548 #endif /* itkMatrixOffsetTransformBase_h */
virtual void SetFixedParameters(const FixedParametersType &) override
SymmetricSecondRankTensor< TParametersValueType, NOutputDimensions > OutputSymmetricSecondRankTensorType
Definition: itkTransform.h:140
virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const override
TCoordRep ValueType
Definition: itkPoint.h:60
A templated class holding a M x N size Matrix.
Definition: itkMatrix.h:46
virtual void PrintSelf(std::ostream &s, Indent indent) const override
Superclass::InputDiffusionTensor3DType InputDiffusionTensor3DType
Point< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
void SetVarCenter(const InputPointType &center)
CovariantVector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
Matrix< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType
Light weight base class for most itk classes.
DiffusionTensor3D< TParametersValueType > OutputDiffusionTensor3DType
Definition: itkTransform.h:144
Superclass::ParametersType ParametersType
Definition: itkTransform.h:117
Superclass::OutputVectorPixelType OutputVectorPixelType
void SetCenter(const InputPointType &center)
OutputPointType TransformPoint(const InputPointType &point) const override
virtual void ComputeJacobianWithRespectToParameters(const InputPointType &x, JacobianType &j) const override
CovariantVector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
Matrix and Offset transformation of a vector space (e.g. space coordinates)
Superclass::FixedParametersType FixedParametersType
static const unsigned int OutputSpaceDimension
Superclass::ParametersValueType ParametersValueType
Superclass::InputSymmetricSecondRankTensorType InputSymmetricSecondRankTensorType
VariableLengthVector< TParametersValueType > InputVectorPixelType
Definition: itkTransform.h:133
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
OutputPointType::ValueType OutputPointValueType
VariableLengthVector< TParametersValueType > OutputVectorPixelType
Definition: itkTransform.h:134
Superclass::TransformCategoryType TransformCategoryType
virtual void ComputeMatrixParameters()
const ParametersType & GetParameters() const override
void SetParameters(const ParametersType &parameters) override
SymmetricSecondRankTensor< TParametersValueType, NInputDimensions > InputSymmetricSecondRankTensorType
Definition: itkTransform.h:138
void SetVarTranslation(const OutputVectorType &translation)
const OutputVectorType & GetTranslation() const
void Compose(const Self *other, bool pre=0)
Transform< TParametersValueType, NInputDimensions, NOutputDimensions > Superclass
virtual bool IsLinear() const override
Superclass::FixedParametersType FixedParametersType
Definition: itkTransform.h:115
const InverseMatrixType & GetInverseMatrix() const
TranslationType::ValueType TranslationValueType
virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const override
Superclass::OutputSymmetricSecondRankTensorType OutputSymmetricSecondRankTensorType
OutputDiffusionTensor3DType TransformDiffusionTensor3D(const InputDiffusionTensor3DType &tensor) const override
void SetVarMatrix(const MatrixType &matrix)
Transform points and vectors from an input space to an output space.
Definition: itkTransform.h:82
Matrix< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(OutputSpaceDimension)> InverseMatrixType
A templated class holding a n-Dimensional vector.
Definition: itkVector.h:62
Superclass::FixedParametersValueType FixedParametersValueType
Array2D< ParametersValueType > JacobianType
Definition: itkTransform.h:125
void SetTranslation(const OutputVectorType &translation)
bool GetInverse(Self *inverse) const
virtual TransformCategoryType GetTransformCategory() const override
const Self & operator=(const Self &)
Generate a unique, increasing time value.
Definition: itkTimeStamp.h:58
DiffusionTensor3D< TParametersValueType > InputDiffusionTensor3DType
Definition: itkTransform.h:143
OutputCovariantVectorType TransformCovariantVector(const InputCovariantVectorType &vector) const override
OutputSymmetricSecondRankTensorType TransformSymmetricSecondRankTensor(const InputSymmetricSecondRankTensorType &tensor) const override
static const unsigned int InputSpaceDimension
virtual void Modified() const
Vector< TParametersValueType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
OutputVectorType::ValueType OutputVectorValueType
Superclass::OutputDiffusionTensor3DType OutputDiffusionTensor3DType
virtual void SetMatrix(const MatrixType &matrix)
const InverseMatrixType & GetVarInverseMatrix() const
ParametersValueType ScalarType
Definition: itkTransform.h:122
Superclass::FixedParametersValueType FixedParametersValueType
Definition: itkTransform.h:116
Superclass::TransformCategoryType TransformCategoryType
Definition: itkTransform.h:453
virtual const MatrixType & GetMatrix() const
Transform< TParametersValueType, NOutputDimensions, NInputDimensions > InverseTransformBaseType
Definition: itkTransform.h:163
Control indentation during Print() invocation.
Definition: itkIndent.h:49
vnl_vector_fixed< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
void SetVarInverseMatrix(const InverseMatrixType &matrix) const
const OutputVectorType & GetOffset() const
static const unsigned int ParametersDimension
virtual const FixedParametersType & GetFixedParameters() const override
InverseTransformBaseType::Pointer InverseTransformBasePointer
Superclass::ParametersValueType ParametersValueType
Definition: itkTransform.h:118
const InputPointType & GetCenter() const
virtual InverseTransformBasePointer GetInverseTransform() const override
Point< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
A templated class holding a geometric point in n-Dimensional space.
Definition: itkPoint.h:51
A templated class holding a n-Dimensional covariant vector.
void SetVarOffset(const OutputVectorType &offset)
OutputVectorType TransformVector(const InputVectorType &vector) const override
InputPointType::ValueType InputPointValueType
Superclass::InputVectorPixelType InputVectorPixelType
void SetOffset(const OutputVectorType &offset)
CovariantVector< TParametersValueType, InputDiffusionTensor3DType::Dimension > InputTensorEigenVectorType
Vector< TParametersValueType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
Superclass::InverseTransformBaseType InverseTransformBaseType