NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkEulerAffineTransform.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef itkEulerAffineTransform_h
16 #define itkEulerAffineTransform_h
17 
19 #include <itkMacro.h>
20 
21 
22 namespace itk
23 {
24 
34 template <
35  class TScalarType=double, // Data type for scalars
36  unsigned int NInputDimensions=3, // Number of dimensions in the input space
37  unsigned int NOutputDimensions=3> // Number of dimensions in the output space
38 class ITK_EXPORT EulerAffineTransform
39  : public SwitchableAffineTransform< TScalarType, NInputDimensions, NOutputDimensions >
40 {
41 public:
43  typedef EulerAffineTransform <TScalarType,
44  NInputDimensions,
45  NOutputDimensions > Self;
46  typedef SwitchableAffineTransform< TScalarType,
47  NInputDimensions,
48  NOutputDimensions > Superclass;
49  typedef SmartPointer<Self> Pointer;
50  typedef SmartPointer<const Self> ConstPointer;
53 
56 
58  itkNewMacro( Self );
59 
61  itkStaticConstMacro(InputSpaceDimension, unsigned int, NInputDimensions);
62  itkStaticConstMacro(OutputSpaceDimension, unsigned int, NOutputDimensions);
63  itkStaticConstMacro(ParametersDimension, unsigned int, 15);
64 
67 
70 
73 
76 
78 
80 
82 
84 
86 
88 
90 
92 
94 
96 
97  typedef typename Superclass::ScaleType ScaleType;
98 
100 
102 
105 
106  typedef Vector<TScalarType,NInputDimensions> COGVectorType;
107 
118  virtual const JacobianType GetJacobian(const InputPointType & point ) const;
119 
120  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point,
121  JacobianType & jacobian ) const;
122 
123 
124 
128  virtual void ComputeJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const;
129 
133  virtual void ComputeInverseJacobianWithRespectToPosition(const InputPointType &x, JacobianType &jac) const;
134 
135 
138 
140  virtual void InverseTransformPoint(const InputPointType & point, InputPointType& out);
141 
146  {
147  typename Self::Pointer inverse = Self::New();
148 
149  GetInv(inverse);
150  this->m_Matrix = inverse->m_Matrix;
151  this->m_Offset = inverse->m_Offset;
152  }
153 
158  void SetParametersFromTransform( const FullAffineTransformType* fullAffine );
159 
161  bool SaveFullAffineMatrix(std::string filename);
162 
164  bool LoadFullAffineMatrix(std::string filename);
165 
167  bool SaveNiftyRegAffineMatrix(std::string filename);
168 
172  void InitialiseUsingCenterOfMass(const COGVectorType& fixedCOM, const COGVectorType& movingCOM)
173  {
174  TranslationType translation;
175 
176  translation.SetSize(NInputDimensions);
177  for (unsigned int i = 0; i < NInputDimensions; i++)
178  {
179  translation[i] = movingCOM[i] - fixedCOM[i];
180  }
181  this->SetTranslation(translation);
182  }
183 
184 protected:
185 
186  EulerAffineTransform(unsigned int outputDims,
187  unsigned int paramDims);
189 
191  virtual ~EulerAffineTransform();
192 
194  void ComputeMatrixAndOffset(void);
195 
197  void ComputeParametersFromMatrixAndOffset(void);
198 
200  void ComputeComponentMatrices() const;
201 
202 private:
203 
204  EulerAffineTransform(const Self & other); // Purposely not implemented
205  const Self & operator=( const Self & ); // Purposely not implemented
206 
207  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_ChangeOrigin;
208  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Rx;
209  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Ry;
210  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Rz;
211  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Trans;
212  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Scale;
213  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_Skew;
214  mutable Matrix<TScalarType,NInputDimensions+1,NInputDimensions+1> m_UnChangeOrigin;
215 
216 }; // class EulerAffineTransform
217 
218 } // namespace itk
219 
220 #ifndef ITK_MANUAL_INSTANTIATION
221 #include "itkEulerAffineTransform.txx"
222 #endif
223 
224 #endif /* __itkEulerAffineTransform_h */
Superclass::JacobianType JacobianType
Definition: itkSwitchableAffineTransform.h:84
Array< double > ScaleType
Definition: itkSwitchableAffineTransform.h:140
Matrix< TScalarType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(OutputSpaceDimension)> InverseMatrixType
Definition: itkSwitchableAffineTransform.h:127
Superclass::FullAffineTransformType FullAffineTransformType
Definition: itkEulerAffineTransform.h:103
vnl_vector_fixed< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVnlVectorType
Definition: itkSwitchableAffineTransform.h:109
Superclass::ScalarType ScalarType
Definition: itkEulerAffineTransform.h:72
Vector< TScalarType, NInputDimensions > COGVectorType
Definition: itkEulerAffineTransform.h:106
Superclass::InputVectorType InputVectorType
Definition: itkEulerAffineTransform.h:75
Matrix< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension), itkGetStaticConstMacro(InputSpaceDimension)> MatrixType
Definition: itkSwitchableAffineTransform.h:122
Superclass::InputCovariantVectorType InputCovariantVectorType
Definition: itkEulerAffineTransform.h:79
Superclass::InverseMatrixType InverseMatrixType
Definition: itkEulerAffineTransform.h:93
Definition: niftkITKAffineResampleImage.cxx:74
Superclass::TranslationType TranslationType
Definition: itkEulerAffineTransform.h:52
Superclass::ScalarType ScalarType
Definition: itkSwitchableAffineTransform.h:87
Superclass::InputVnlVectorType InputVnlVectorType
Definition: itkEulerAffineTransform.h:83
Superclass::MatrixType MatrixType
Definition: itkEulerAffineTransform.h:91
SwitchableAffineTransform< TScalarType, NInputDimensions, NOutputDimensions > Superclass
Definition: itkEulerAffineTransform.h:48
Superclass::RotationType RotationType
Definition: itkEulerAffineTransform.h:51
Superclass::ParametersType ParametersType
Definition: itkEulerAffineTransform.h:66
Vector< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
Definition: itkSwitchableAffineTransform.h:91
Euler Affine transform.
Definition: itkEulerAffineTransform.h:38
Superclass::ParametersType ParametersType
Definition: itkSwitchableAffineTransform.h:81
Point< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
Definition: itkSwitchableAffineTransform.h:117
FullAffineTransformType::Pointer FullAffineTransformPointer
Definition: itkSwitchableAffineTransform.h:132
Vector< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
Definition: itkSwitchableAffineTransform.h:93
Superclass::OutputVectorType OutputVectorType
Definition: itkEulerAffineTransform.h:77
void InvertTransformationMatrix()
Definition: itkEulerAffineTransform.h:145
Superclass::OutputVnlVectorType OutputVnlVectorType
Definition: itkEulerAffineTransform.h:85
Superclass::OutputVectorType SkewMinorType
Definition: itkEulerAffineTransform.h:101
Point< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
Definition: itkSwitchableAffineTransform.h:114
Array< double > RotationType
Definition: itkSwitchableAffineTransform.h:138
GLint GLint GLint GLint GLint x
Definition: glew.h:1236
CovariantVector< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputCovariantVectorType
Definition: itkSwitchableAffineTransform.h:98
Array< double > TranslationType
Definition: itkSwitchableAffineTransform.h:136
Superclass::OutputPointType OutputPointType
Definition: itkEulerAffineTransform.h:89
Superclass::FullAffineTransformPointer FullAffineTransformPointer
Definition: itkEulerAffineTransform.h:104
EulerAffineTransform< TScalarType, NInputDimensions, NOutputDimensions > Self
Definition: itkEulerAffineTransform.h:45
void InitialiseUsingCenterOfMass(const COGVectorType &fixedCOM, const COGVectorType &movingCOM)
Definition: itkEulerAffineTransform.h:172
Superclass::ScaleType ScaleType
Definition: itkEulerAffineTransform.h:97
Superclass::OutputCovariantVectorType OutputCovariantVectorType
Definition: itkEulerAffineTransform.h:81
Matrix transformations, with switchable Degrees Of Freedom.
Definition: itkSwitchableAffineTransform.h:58
Superclass::InputPointType CenterType
Definition: itkEulerAffineTransform.h:95
Our base transform class. Cant think of a better name.
Definition: itkUCLBaseTransform.h:33
Superclass::JacobianType JacobianType
Definition: itkEulerAffineTransform.h:69
SmartPointer< Self > Pointer
Definition: itkEulerAffineTransform.h:49
GLsizei const GLcharARB ** string
Definition: glew.h:5194
Superclass::InputPointType InputPointType
Definition: itkEulerAffineTransform.h:87
CovariantVector< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputCovariantVectorType
Definition: itkSwitchableAffineTransform.h:101
vnl_vector_fixed< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVnlVectorType
Definition: itkSwitchableAffineTransform.h:106
SmartPointer< const Self > ConstPointer
Definition: itkEulerAffineTransform.h:50
AffineTransform< TScalarType, NInputDimensions > FullAffineTransformType
Definition: itkSwitchableAffineTransform.h:131
Superclass::OutputVectorType SkewMajorType
Definition: itkEulerAffineTransform.h:99