ANIMA  4.0
animaDirectionScaleSkewTransform.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <iostream>
4 #include <itkMatrixOffsetTransformBase.h>
5 
6 namespace anima
7 {
8 
9  template < class TScalarType=double > // Data type for scalars (double or double)
11  public itk::MatrixOffsetTransformBase< TScalarType, 3 >
12  {
13  public:
16  typedef itk::MatrixOffsetTransformBase< TScalarType, 3 > Superclass;
17  typedef itk::SmartPointer<Self> Pointer;
18  typedef itk::SmartPointer<const Self> ConstPointer;
19 
21  itkNewMacro(Self);
22 
24  itkTypeMacro(DirectionScaleSkewTransform, MatrixOffsetTransformBase);
25 
27  itkStaticConstMacro(SpaceDimension, unsigned int, 3);
28  itkStaticConstMacro(InputSpaceDimension, unsigned int, 3);
29  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 3);
30  itkStaticConstMacro(ParametersDimension, unsigned int, 4);
31 
33  typedef typename Superclass::ParametersType ParametersType;
34  typedef typename Superclass::JacobianType JacobianType;
35  typedef typename Superclass::ScalarType ScalarType;
36  typedef typename Superclass::InputPointType InputPointType;
37  typedef typename Superclass::OutputPointType OutputPointType;
38  typedef typename Superclass::InputVectorType InputVectorType;
39  typedef typename Superclass::OutputVectorType OutputVectorType;
40  typedef typename Superclass::InputVnlVectorType InputVnlVectorType;
41  typedef typename Superclass::OutputVnlVectorType OutputVnlVectorType;
42  typedef typename Superclass::InputCovariantVectorType
44  typedef typename Superclass::OutputCovariantVectorType
46  typedef typename Superclass::MatrixType MatrixType;
47  typedef itk::Matrix <ScalarType,4,4> HomogeneousMatrixType;
48  typedef typename Superclass::InverseMatrixType InverseMatrixType;
49  typedef typename Superclass::CenterType CenterType;
50  typedef typename Superclass::OffsetType OffsetType;
51  typedef typename Superclass::TranslationType TranslationType;
52 
53  virtual void SetParameters(const ParametersType & parameters) override;
54  virtual const ParametersType& GetParameters() const override;
55 
56  virtual void SetIdentity() override;
57 
58  virtual void SetGeometry(HomogeneousMatrixType &matrix, bool update = true);
59 
60  void SetLogScale(ScalarType scale, bool update = true);
61  itkGetConstReferenceMacro(LogScale, ScalarType);
62 
63  void SetLogFirstSkew(ScalarType skew, bool update = true);
64  itkGetConstReferenceMacro(LogFirstSkew, ScalarType);
65 
66  void SetLogSecondSkew(ScalarType skew, bool update = true);
67  itkGetConstReferenceMacro(LogSecondSkew, ScalarType);
68 
69  void SetUniqueTranslation(ScalarType translation, bool update = true);
70  itkGetConstReferenceMacro(UniqueTranslation, ScalarType);
71 
72  void SetUniqueDirection(unsigned int direction);
73  itkGetConstReferenceMacro(UniqueDirection, unsigned int);
74 
75  virtual const itk::Vector <TScalarType,12>& GetLogVector() const {return m_LogVector;}
76  virtual const vnl_matrix <TScalarType>& GetLogTransform() const {return m_LogTransform;}
77 
78  protected:
80  : Superclass(ParametersDimension)
81  {
82  this->InitializeParameters();
83  }
84 
85  DirectionScaleSkewTransform (unsigned int ParamersDim)
86  : Superclass(ParamersDim)
87  {
88  this->InitializeParameters();
89  }
90 
92 
93  void PrintSelf(std::ostream &os, itk::Indent indent) const override;
94 
95  virtual void ComputeMatrix() override;
96  virtual void GetInternalLogarithm();
97  virtual void GetInternalExponential();
98  virtual void InternalApplyGeometry(MatrixType &linearMatrix, OffsetType &offset);
99 
100  vnl_matrix <TScalarType> m_LogTransform, m_ExpTransform;
101  HomogeneousMatrixType m_Geometry, m_GeometryInv;
102 
103  private:
104  DirectionScaleSkewTransform(const Self&); //purposely not implemented
105  void operator=(const Self&); //purposely not implemented
106 
107  void InitializeParameters()
108  {
109  m_LogVector.Fill(itk::NumericTraits<TScalarType>::Zero);
110  m_LogTransform.set_size(4,4);
111  m_ExpTransform.set_size(4,4);
112 
113  m_LogScale = 0;
114  m_LogFirstSkew = 0;
115  m_LogSecondSkew = 0;
116  m_UniqueTranslation = 0;
117  m_UniqueDirection = 1; // 0 is the X axis, 1 the Y axis, 2 the Z axis of the image
118 
119  m_Geometry.SetIdentity();
120  m_GeometryInv.SetIdentity();
121 
122  this->ComputeMatrix();
123  }
124 
125  ScalarType m_LogScale;
126  ScalarType m_LogFirstSkew, m_LogSecondSkew;
127  ScalarType m_UniqueTranslation;
128 
129  unsigned int m_UniqueDirection;
130 
131  itk::Vector <TScalarType,12> m_LogVector;
132  }; // class DirectionScaleSkewTransform
133 
134  template <class TScalarType=double> // Data type for scalars (double or double)
136  public DirectionScaleSkewTransform <TScalarType>
137  {
138  public:
142  typedef itk::SmartPointer<Self> Pointer;
143  typedef itk::SmartPointer<const Self> ConstPointer;
144 
145  typedef typename Superclass::ParametersType ParametersType;
146  typedef typename Superclass::MatrixType MatrixType;
147  typedef typename Superclass::OffsetType OffsetType;
148 
150  itkNewMacro(Self);
151 
154 
156  itkStaticConstMacro(ParametersDimension, unsigned int, 2);
157 
158  virtual void SetParameters(const ParametersType & parameters) override;
159  virtual const ParametersType& GetParameters() const override;
160 
161  protected:
163  : Superclass(ParametersDimension) {}
164 
165  virtual void GetInternalLogarithm() override;
166  virtual void GetInternalExponential() override;
167  virtual void InternalApplyGeometry(MatrixType &linearMatrix, OffsetType &offset) override;
168 
169  }; // class DirectionScaleTransform
170 
171 
172  template <class TScalarType=double> // Data type for scalars (double or double)
174  public DirectionScaleSkewTransform <TScalarType>
175  {
176  public:
180  typedef itk::SmartPointer<Self> Pointer;
181  typedef itk::SmartPointer<const Self> ConstPointer;
182 
183  typedef typename Superclass::ParametersType ParametersType;
184  typedef typename Superclass::MatrixType MatrixType;
185  typedef typename Superclass::OffsetType OffsetType;
186 
188  itkNewMacro(Self)
189 
190 
192 
193 
194  itkStaticConstMacro(ParametersDimension, unsigned int, 1);
195 
196  virtual void SetParameters(const ParametersType & parameters) override;
197  virtual const ParametersType& GetParameters() const override;
198 
199  protected:
201  : Superclass(ParametersDimension) {}
202 
203  virtual void GetInternalLogarithm() override;
204  virtual void GetInternalExponential() override;
205  virtual void InternalApplyGeometry(MatrixType &linearMatrix, OffsetType &offset) override;
206 
207  }; // class DirectionTransform
208 
209 } // namespace anima
210 
virtual void SetParameters(const ParametersType &parameters) override
itk::SmartPointer< const Self > ConstPointer
itk::MatrixOffsetTransformBase< TScalarType, 3 > Superclass
virtual const ParametersType & GetParameters() const override
void SetLogScale(ScalarType scale, bool update=true)
Superclass::InputCovariantVectorType InputCovariantVectorType
void SetLogSecondSkew(ScalarType skew, bool update=true)
Superclass::OutputCovariantVectorType OutputCovariantVectorType
void SetLogFirstSkew(ScalarType skew, bool update=true)
itk::SmartPointer< const Self > ConstPointer
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::Matrix< ScalarType, 4, 4 > HomogeneousMatrixType
void SetUniqueTranslation(ScalarType translation, bool update=true)
anima::DirectionScaleSkewTransform< TScalarType > Superclass
Superclass::ParametersType ParametersType
virtual const vnl_matrix< TScalarType > & GetLogTransform() const
virtual const itk::Vector< TScalarType, 12 > & GetLogVector() const
Superclass::OutputVnlVectorType OutputVnlVectorType
anima::DirectionScaleSkewTransform< TScalarType > Superclass
Superclass::InputVnlVectorType InputVnlVectorType
virtual void InternalApplyGeometry(MatrixType &linearMatrix, OffsetType &offset)
virtual void SetGeometry(HomogeneousMatrixType &matrix, bool update=true)