NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
itkPerspectiveProjectionTransform.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 itkPerspectiveProjectionTransform_h
16 #define itkPerspectiveProjectionTransform_h
17 
18 #include <itkExceptionObject.h>
19 #include <iostream>
20 #include <itkMatrix.h>
21 #include <itkTransform.h>
22 
23 namespace itk
24 {
25 
38 template <class TScalarType=double> // Data type for scalars (float or double)
39 class ITK_EXPORT PerspectiveProjectionTransform :
40  public Transform< TScalarType, 3, 2 >
41 {
42 public:
44  itkStaticConstMacro(InputSpaceDimension, unsigned int, 3);
45  itkStaticConstMacro(OutputSpaceDimension, unsigned int, 2);
46 
48  itkStaticConstMacro(SpaceDimension, unsigned int, 3);
49  itkStaticConstMacro(ParametersDimension, unsigned int, 3);
50 
53  typedef Transform< TScalarType,
54  itkGetStaticConstMacro(InputSpaceDimension),
55  itkGetStaticConstMacro(OutputSpaceDimension)> Superclass;
56 
57  typedef SmartPointer<Self> Pointer;
58  typedef SmartPointer<const Self> ConstPointer;
59 
61  itkTypeMacro( PerspectiveProjectionTransform, Transform );
62 
64  itkNewMacro( Self );
65 
67  typedef typename Superclass::ScalarType ScalarType;
68 
70  typedef typename Superclass::ParametersType ParametersType;
71 
74 
76  typedef Matrix<TScalarType,
77  itkGetStaticConstMacro(InputSpaceDimension + 1),
78  itkGetStaticConstMacro(InputSpaceDimension + 1)> MatrixType;
79 
81  typedef Vector<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType;
82  typedef Vector<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType;
83 
85  typedef Point<TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType;
86  typedef Point<TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType;
87 
92  void SetParameters( const ParametersType & parameters );
93  const ParametersType & GetParameters() const;
94 
96  virtual void SetFixedParameters( const ParametersType & ) {}
97 
99  virtual const ParametersType& GetFixedParameters(void) const
100  { return this->m_FixedParameters; }
101 
105  void SetFocalDistance( TScalarType focalDistance )
106  { this->m_Parameters[0] = focalDistance; this->Modified(); }
107 
109  double GetFocalDistance( void ) const
110  { return this->m_Parameters[0]; }
111 
113  void SetOriginIn2D( TScalarType u0, TScalarType v0 )
114  {
115  this->m_Parameters[1] = u0;
116  this->m_Parameters[2] = v0;
117  this->Modified();
118  }
119 
121  void SetK1IsNegative( void ) { this->m_k1 = 1.; this->Modified(); }
123  void SetK2IsNegative( void ) { this->m_k2 = 1.; this->Modified(); }
124 
126  void GetOriginIn2D( TScalarType &u0, TScalarType &v0 )
127  {
128  u0 = this->m_Parameters[1];
129  v0 = this->m_Parameters[2];
130  }
131 
133  MatrixType GetMatrix() const;
134 
138  OutputPointType TransformPoint(const InputPointType &point ) const;
139 
141  virtual const JacobianType GetJacobian(const InputPointType &point ) const;
142 
143  virtual void ComputeJacobianWithRespectToParameters(const InputPointType & point,
144  JacobianType & jacobian ) const;
145 
146 protected:
149  void PrintSelf(std::ostream &os, Indent indent) const;
150 
151  // Coefficient (1 or -1) indicating that the the 'x' dimension of the 2D projection is inverted
152  double m_k1;
153  // Coefficient (1 or -1) indicating that the the 'y' dimension of the 2D projection is inverted
154  double m_k2;
155 
156 
157 private:
158  PerspectiveProjectionTransform(const Self&); //purposely not implemented
159  void operator=(const Self&); //purposely not implemented
160 
161 }; //class PerspectiveProjectionTransform:
162 
163 
164 
165 } // namespace itk
166 
167 // Define instantiation macro for this template.
168 #define ITK_TEMPLATE_PerspectiveProjectionTransform(_, EXPORT, x, y) namespace itk { \
169  _(1(class EXPORT PerspectiveProjectionTransform< ITK_TEMPLATE_1 x >)) \
170  namespace Templates { typedef PerspectiveProjectionTransform< ITK_TEMPLATE_1 x > \
171  PerspectiveProjectionTransform##y; } \
172  }
173 
174 #if ITK_TEMPLATE_EXPLICIT
175 # include "Templates/itkPerspectiveProjectionTransform+-.h"
176 #endif
177 
178 #if ITK_TEMPLATE_TXX
179 # include "itkPerspectiveProjectionTransform.txx"
180 #endif
181 
182 #endif /* __itkPerspectiveProjectionTransform_h */
virtual void SetFixedParameters(const ParametersType &)
Definition: itkPerspectiveProjectionTransform.h:96
Superclass::ScalarType ScalarType
Definition: itkPerspectiveProjectionTransform.h:64
Superclass::ParametersType ParametersType
Definition: itkPerspectiveProjectionTransform.h:70
void SetFocalDistance(TScalarType focalDistance)
Definition: itkPerspectiveProjectionTransform.h:105
Matrix< TScalarType, itkGetStaticConstMacro(InputSpaceDimension+1), itkGetStaticConstMacro(InputSpaceDimension+1)> MatrixType
Definition: itkPerspectiveProjectionTransform.h:78
Definition: niftkITKAffineResampleImage.cxx:74
virtual const ParametersType & GetFixedParameters(void) const
Definition: itkPerspectiveProjectionTransform.h:99
vnl_matrix< double > MatrixType
Definition: itkSuperEllipseFit.h:32
Point< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputPointType
Definition: itkPerspectiveProjectionTransform.h:86
PerspectiveProjectionTransform of a vector space (e.g. space coordinates)
Definition: itkPerspectiveProjectionTransform.h:39
Transform< TScalarType, itkGetStaticConstMacro(InputSpaceDimension), itkGetStaticConstMacro(OutputSpaceDimension)> Superclass
Definition: itkPerspectiveProjectionTransform.h:55
double m_k1
Definition: itkPerspectiveProjectionTransform.h:152
void SetK2IsNegative(void)
Definition: itkPerspectiveProjectionTransform.h:123
SmartPointer< const Self > ConstPointer
Definition: itkPerspectiveProjectionTransform.h:58
void GetOriginIn2D(TScalarType &u0, TScalarType &v0)
Definition: itkPerspectiveProjectionTransform.h:126
Superclass::JacobianType JacobianType
Definition: itkPerspectiveProjectionTransform.h:73
double m_k2
Definition: itkPerspectiveProjectionTransform.h:154
SmartPointer< Self > Pointer
Definition: itkPerspectiveProjectionTransform.h:57
void SetK1IsNegative(void)
Definition: itkPerspectiveProjectionTransform.h:121
GLfloat v0
Definition: glew.h:1832
void SetOriginIn2D(TScalarType u0, TScalarType v0)
Definition: itkPerspectiveProjectionTransform.h:113
Point< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputPointType
Definition: itkPerspectiveProjectionTransform.h:85
double GetFocalDistance(void) const
Definition: itkPerspectiveProjectionTransform.h:109
Vector< TScalarType, itkGetStaticConstMacro(InputSpaceDimension)> InputVectorType
Definition: itkPerspectiveProjectionTransform.h:81
Vector< TScalarType, itkGetStaticConstMacro(OutputSpaceDimension)> OutputVectorType
Definition: itkPerspectiveProjectionTransform.h:82
PerspectiveProjectionTransform Self
Definition: itkPerspectiveProjectionTransform.h:52
itk::Array2D< double > JacobianType
Definition: EulerAffine2DJacobianTest.cxx:28