CTL  0.6.1
Computed Tomography Library
projectionmatrix.h
Go to the documentation of this file.
1 #ifndef CTL_PROJECTIONMATRIX_H
2 #define CTL_PROJECTIONMATRIX_H
3 
4 #include "matrix.h"
5 
6 namespace CTL {
7 namespace mat {
96 class ProjectionMatrix : public Matrix<3, 4>
97 {
98 public:
99  // normalization modes for directionSourceToPixel()
101  NoNormalization = 0,
102  NormalizeAsUnitVector = 1,
103  NormalizeByX = 2,
104  NormalizeByY = 3,
105  NormalizeByChannel = 2,
106  NormalizeByRow = 3
107  };
108 
109  ProjectionMatrix() = default;
110  ProjectionMatrix(const Matrix<3, 4>& other);
111  using Matrix<3, 4>::Matrix;
112  using Matrix<3, 4>::operator=;
113 
114  // # factories
115  static ProjectionMatrix compose(const Matrix<3, 3>& M, const Matrix<3, 1>& p4);
116  static ProjectionMatrix
117  compose(const Matrix<3, 3>& K, const Matrix<3, 3>& R, const Matrix<3, 1>& source);
118 
119  // # modifications
120  void shiftDetectorOrigin(const Matrix<2, 1>& translation);
121  void shiftDetectorOrigin(double translationX, double translationY);
122  void changeDetectorResolution(double resamplingFactor);
123  void changeDetectorResolution(double resamplingFactorX, double resamplingFactorY);
124  void normalize();
125 
126  // # getter
127  // normalized by normal vector of principal plane [P(2,0) P(2,1) P(2,2)]
129  bool isNormalized() const;
130  // common submatrices: P = [M|p4]
131  Matrix<3, 3> M() const;
132  Matrix<3, 1> p4() const;
133  // direction vectors
134  Matrix<3, 1> directionSourceToPixel(const Matrix<2, 1>& pixelCoordinates,
135  NormalizationMode normalizationMode = NoNormalization) const;
136  Matrix<3, 1> directionSourceToPixel(double x, double y,
137  NormalizationMode normalizationMode = NoNormalization) const;
139  // extrinsic parameters
142  Matrix<3, 3> rotationMatR() const;
143  // intrinsic parameters
144  Matrix<3, 3> intrinsicMatK() const;
145  // intrinsic convenience functions
147  Matrix<2, 1> focalLength() const;
148  double skewCoefficient() const;
149  double skewAngle() const;
150  double magnificationX(double X, double Y, double Z) const;
151  double magnificationX(const Matrix<3, 1>& worldCoordinate = { 0.0, 0.0, 0.0 }) const;
152  double magnificationY(double X, double Y, double Z) const;
153  double magnificationY(const Matrix<3, 1>& worldCoordinate = { 0.0, 0.0, 0.0 }) const;
154 
155  // # other/convenience
156  Matrix<2, 1> projectOntoDetector(double X, double Y, double Z) const;
157  Matrix<2, 1> projectOntoDetector(const Matrix<3, 1>& worldCoordinate) const;
158 };
159 
160 
165  : Matrix<3, 4>(other)
166 {
167 }
168 
169 } // namespace mat
170 } // namespace CTL
171 
174 #endif // CTL_PROJECTIONMATRIX_H
Specialized sub-class of Matrix<3, 4> to represent a projection matrix.
Definition: projectionmatrix.h:96
Matrix< 3, 3 > M() const
Definition: projectionmatrix.cpp:169
NormalizationMode
Definition: projectionmatrix.h:100
double magnificationY(double X, double Y, double Z) const
Definition: projectionmatrix.cpp:381
bool isNormalized() const
Definition: projectionmatrix.cpp:160
Matrix< 3, 3 > intrinsicMatK() const
Definition: projectionmatrix.cpp:305
static ProjectionMatrix compose(const Matrix< 3, 3 > &M, const Matrix< 3, 1 > &p4)
Definition: projectionmatrix.cpp:32
void shiftDetectorOrigin(const Matrix< 2, 1 > &translation)
Definition: projectionmatrix.cpp:67
Matrix< 3, 1 > directionSourceToPixel(const Matrix< 2, 1 > &pixelCoordinates, NormalizationMode normalizationMode=NoNormalization) const
Definition: projectionmatrix.cpp:186
ProjectionMatrix normalized() const
Definition: projectionmatrix.cpp:146
Matrix< 2, 1 > projectOntoDetector(double X, double Y, double Z) const
Definition: projectionmatrix.cpp:435
Matrix< 2, 1 > focalLength() const
Definition: projectionmatrix.cpp:330
Matrix< 3, 3 > rotationMatR() const
Definition: projectionmatrix.cpp:293
double skewAngle() const
Definition: projectionmatrix.cpp:347
double magnificationX(double X, double Y, double Z) const
Definition: projectionmatrix.cpp:356
Matrix< 3, 1 > sourcePosition() const
Definition: projectionmatrix.cpp:276
double skewCoefficient() const
Definition: projectionmatrix.cpp:339
Matrix< 3, 1 > principalRayDirection() const
Definition: projectionmatrix.cpp:250
Matrix< 3, 1 > p4() const
Definition: projectionmatrix.cpp:178
Matrix< 2, 1 > principalPoint() const
Definition: projectionmatrix.cpp:316
This template class is an abstraction of a small matrix with a size known at compile time.
Definition: matrix.h:21
void normalize()
Definition: projectionmatrix.cpp:126
Matrix< 3, 1 > translationCTS() const
Definition: projectionmatrix.cpp:264
void changeDetectorResolution(double resamplingFactor)
Definition: projectionmatrix.cpp:94