public class Projection
extends java.lang.Object
implements java.io.Serializable
The following text defines all variable names used in the member documentation and explains the projection representations.
It is recommended to refer to chapter 6 ("Camera Models") of [Hartley and Zisserman: Multiple View %Geometry. Cambridge Univ. Press] for further information.
This is usually defined by explicitly modeling a camera coordinate system and then defining that the camera looks into positive or negative z direction (implying that the other side is invisible). Then, the 3rd coordinate w of the projected point (w*u, w*v, w) can be used to clip either points with a negative or positive depth value w.
In order to define the visible half space, we use the sign of the homogeneous
coordinate of p and choose the convention that visible points result in a positive
value for a volume point given with a positive homogeneous component.
This choice is arbitrary. But since a choice has to be made anyways
and to avoid complicating the internal formulas, we have chosen this convention.
If your P matrix returns a negative third coordinate for a voxel which which should
be visible, then just multiply the whole matrix by -1 before using it with this
class. It should then fulfill the condition
for all voxels in front of the camera. Note that this negative scaling does not affect the
resulting pixel coordinate (due to the homogeneous division) but only flips the visibility
coordinate.
Note that the 3x4 matrix does does not rely on a definition of a camera coordinate system but merely is a direct mapping from world coordinates to pixels. Therefore, there is also no notion of "viewing in +z or -z direction". For understanding the structure and effect of 3x4 projection matrix (using an intermediate camera coordinate system), you might want to look at the decomposition into intrinsic and extrinsic parameters described in the following section.
The focal lengths and
are measured in pixels if the
K matrix is given in the form above. This implies that they should be equal for perfectly square
pixels. The focal length is the distance from the camera center to the principal point on the image
plane. If one further composes K into a camera matrix working in world coordinate dimensions only
(mapping to world coordinates instead of pixels) and a separate scaling transform for translating
image coordinates to pixel values, one obtains the additional information about the real focal length
and the pixel size. These parameters, however, are not necessary for a pure establishment of the
relation between volume and pixel coordinates. They are merely augmenting the projection description
with additional geometric information.
Finally, the skew parameter is usually zero, unless your camera's pixel axes are not
perpendicular. For CCDs this means that they have not been produced with accurately aligned
axes. A skew can never arise by inclined arrangements of camera and
detector.
The conversion to/from a 3x4 P matrix as described above is "lossless" since any scaling factor is stored in s and the same assumptions are made concerning the viewing direction (positive third coordinate for points in front of the camera). Again, the world coordinates as well as the image coordinates are assumed to represent infinitesimally small points in 3D or 2D, respectively. Therefore, if you work with voxels or pixels of finite size, always use their center coordinates.
The representation using intrinsic and extrinsic parameters is the best-suited for further computations. Therefore, this representation is used internally for storing a projection in this class.
Note that the K/R/t representation always represents scaling effects with the K matrix of intrinsic parameters. Only rotations and translations are stored in R and t.
OpenGL has two so-called "matrix modes": GL_MODELVIEW and GL_PROJECTION. The modelview matrix basically covers all transformations from object coordinates to eye coordinates (the OpenGL term for camera coordinates). This includes translation, rotation, and also scaling (e.g. of standard unit cubes to another size). The projection matrix then covers the projective part. (However, OpenGL in the end just multiplies both matrices so that the user may also "abuse" the two matrices.)
The first difference to the intrinsic / extrinsic representation using K, R, and t is therefore that scaling effects are modeled twice in OpenGL (in the modelview as well as in the projection matrix) and only once using the K/R/t representation (namely in K's focal lengths). This is due to OpenGL's concept of not using a world coordinate system but standard objects of normalized size.
Moreover, OpenGL uses homogeneous 4x4 matrices throughout the full transformation pipeline. It separates depth from the z coordinate by adding an additional row to the coordinates:
As a last adjustment, it has to be noted that OpenGL uses a so-called "normalized
device coordinate system" which represents all pixels to be drawn in a
cube (where the 3rd coordinate represents the normalized depth). The
transformation from these normalized coordinates to the screen pixel coordinates is
done using the viewport transform in OpenGL. This final transformation has to be appended
to a given OpenGL projection matrix in order to obtain the full transformation pipeline
from world coordinates to screen pixel coordinates. In contrast to the other projection
representations, OpenGL also defines 6 clipping planes (top, bottom, left, right, near,
and far). That's the reason why computeGLMatrices() has to know these 6 parameters
for a proper conversion. (fromGL() only needs the viewport for the correct mapping from
normalized device coordinates to window coordinates.)
Summarizing, the following adjustments have to be made between the K/R/t and the OpenGL representation:
Warning: Mind that OpenGL uses column-major order while the NuDeLib uses row-major matrices. This class' OpenGL connections, however, interface with OpenGL using C-style arrays in column-major order so that you can directly load/get them in OpenGL.
See also [Wright et al.: OpenGL SuperBible. Sams] and [Shreiner et al.: OpenGL Programming Guide] for more information on OpenGL.
computePrincipalAxis()
, and
Modifier and Type | Class and Description |
---|---|
static class |
Projection.CameraAxisDirection |
Constructor and Description |
---|
Projection()
Default constructor.
|
Projection(double[] glProjectionGlVec,
double[] glModelviewGlVec,
int[] glViewport)
Construct this projection from GL matrices.
|
Projection(SimpleMatrix P)
Construct this projection from a 3x4 Matrix.
|
Modifier and Type | Method and Description |
---|---|
SimpleVector |
computeCameraCenter()
Compute the camera center in world coordinates.
|
double |
computeDepth(SimpleVector v)
Computes a given point's Eucledian distance to the camera.
|
void |
computeGLMatrices(int imgMinU,
int imgMinV,
int imgSizeU,
int imgSizeV,
double distanceNear,
double distanceFar,
double[] glProjectionGlVec,
double[] glModelviewGlVec)
Compute the 4x4 OpenGL projection and modelview matrices from this Projection.
|
boolean |
computeGLMatrices(int imgMinU,
int imgMinV,
int imgSizeU,
int imgSizeV,
SimpleVector cubmin,
SimpleVector cubmax,
double[] glProjectionGlVec,
double[] glModelviewGlVec)
Compute the 4x4 OpenGL projection and modelview matrices from this Projection.
|
SimpleVector |
computeOffset(SimpleVector sizeUV)
This convenience method computes the offset from the image center to the principal point.
|
SimpleMatrix |
computeP()
Computes the 3x4 projection matrix
![]() |
SimpleVector |
computePrincipalAxis()
Compute the principal axis direction in world coordinates.
|
SimpleVector |
computeRayDirection(SimpleVector p)
Computes the direction of the ray corresponding to a given pixel.
|
double[] |
computeSourceToDetectorDistance(SimpleVector spacingUV)
This convenience method computes the source-to-detector distance in world corrdinate dimensions.
|
SimpleMatrix |
getK()
Returns a const reference to the K matrix of intrinsic parameters.
|
java.lang.String |
getPMatrixSerialization()
This method is only used for XML serialization.
|
SimpleVector |
getPrincipalPoint()
Returns the principal point in pixels.
|
SimpleMatrix |
getR()
Returns a const reference to the rotation matrix R.
|
SimpleMatrix |
getRt()
Returns all extrinsic parameters (R and t) in a homogeneous rigid motion matrix.
|
SimpleMatrix |
getRTKinv() |
double |
getS()
Returns a const reference to the scaling.
|
SimpleVector |
getT()
Returns a const reference to the translation vector t.
|
double |
getViewingDirection()
Returns the viewing direction of the camera with respect to
the z axis of the camera coordinate system
The viewing direction can be either in positive or negative
![]() |
void |
initFromGL(double[] glProjectionGlVec,
double[] glModelviewGlVec,
int[] glViewport)
Gets all projection parameters from a given OpenGL projection matrix.
|
void |
initFromP(SimpleMatrix P)
Define the projection using a 3x4 projection matrix.
|
void |
initFromSKRT(double s,
SimpleMatrix K,
SimpleMatrix R,
SimpleVector t)
Set the projection's intrinsic and extrinsic parameters all at once.
|
void |
initToExampleCamera()
Creates a exemplary perspective projection.
|
boolean |
intersectRayWithCuboid(SimpleVector p,
SimpleVector cubmin,
SimpleVector cubmax,
double[] distanceNearFar,
SimpleVector C,
SimpleVector d)
Computes the two intersections of a ray with a cuboid, called entry and
exit point where the ray is defined by this projection and the given pixel.
|
double |
project(SimpleVector volumePoint,
SimpleVector pixel)
Projects a given voxel to a pixel and determines its visibility.
|
void |
setKFromDistancesSpacingsSizeOffset(double sourceToDetector,
SimpleVector spacingUV,
SimpleVector sizeUV,
SimpleVector offset,
double dir,
double skew)
Constructs the K matrix from distance and offset parameters.
|
void |
setKValue(SimpleMatrix K)
Set the intrinsic parameters K of the projection.
|
void |
setPMatrixSerialization(java.lang.String projectionMatrix)
This method is only used for XML serialization.
|
void |
setPrincipalPointValue(SimpleVector p)
Sets the principal point in pixels.
|
double |
setRtFromCircularTrajectory(SimpleVector rotationCenter,
SimpleVector rotationAxis,
double sourceToAxisDistance,
SimpleVector centerToCameraAtZeroAngle,
Projection.CameraAxisDirection uDirection,
Projection.CameraAxisDirection vDirection,
double rotationAngle)
Constructs the extrinsic parameters (R and t) of this projection from the extrensic parameters
source-to-isocenter distance, rotation axis, rotation angle, and viewing axis.
|
void |
setRtValue(SimpleMatrix Rt)
Set the extrinsic parameters of the projection.
|
void |
setRValue(SimpleMatrix R)
Set the rotation part of the extrinsic parameters of the projection.
|
void |
setSValue(double s)
Set the (positive) scaling of the projection.
|
void |
setTVector(SimpleVector t)
Set the translation part of the extrinsic parameters of the projection.
|
void |
setViewingDirectionValue(double dir)
Set the viewing direction of the camera with respect to the z
axis of the camera coordinate system.
|
java.lang.String |
toString()
Returns a String representation of this projection's 3x4 matrix.
|
public Projection()
public Projection(SimpleMatrix P)
initFromP(SimpleMatrix P)
public Projection(double[] glProjectionGlVec, double[] glModelviewGlVec, int[] glViewport)
public void initToExampleCamera()
Warning: This exemplary camera may be subject to change in future versions. Only use it when first experimenting with this class. Set up your own camera for any application.
public void initFromP(SimpleMatrix P)
P
- A 3x4 projection matrix.
See the class documentation for further details.public void initFromGL(double[] glProjectionGlVec, double[] glModelviewGlVec, int[] glViewport)
Remark: Usually, the following OpenGL commands have to be used for getting OpenGL's
projection:
double glProjectionGlVec[16];
double glModelviewGlVec[16];
int glViewport[4];
glGetDoublev(GL_PROJECTION_MATRIX, glProjectionGlVec);
glGetDoublev(GL_MODELVIEW_MATRIX, glModelviewGlVec);
glGetIntegerv(GL_VIEWPORT, glViewport);
Projection proj;
proj.fromGL(glProjectionGlVec, glModelviewGlVec, glViewport);
Remark: Internally, the following 3x4 matrix is computed using the conversion matrix
and the product
of the given
4x4 matrices:
Warning: Mind that OpenGL uses C-style arrays in column-major order whereas the NuDeLib uses row-major matrices. However, you shouldn't bother with that since this methods takes glProjectionGlVec and glModelviewGlVec in a column-major C-style array as you get it using OpenGL's glGetDoublev() function.
glProjectionGlVec
- A given OpenGL projection matrix. This is a C-style array of
16 values, representing a 4x4 matrix in column-major / OpenGL order.glModelviewGlVec
- A given OpenGL modelview matrix. This is a C-style array of
16 values, representing a 4x4 matrix in column-major / OpenGL order.glViewport
- A given OpenGL viewport specification in the form
[imgMinU, imgMinV, imgSizeU, imgSizeV], where
public void initFromSKRT(double s, SimpleMatrix K, SimpleMatrix R, SimpleVector t)
s
- A positive scaling factor.
See the class documentation for further details.K
- A 3x3 intrinsic camera matrix.
See the class documentation for further details.R
- A 3x3 rotation matrix, representing the extrinsic rotation of the camera.
See the class documentation for further details.t
- A 3x1 translation vector, representing the translation of the camera.
See the class documentation for further details.setSValue(double)
,
setKValue(SimpleMatrix)
,
setRValue(SimpleMatrix R)
,
setTVector(SimpleVector)
public void setSValue(double s)
s
- A positive scaling factor.
See the class documentation for further details.initFromSKRT(double s, SimpleMatrix K, SimpleMatrix R, SimpleVector t)
public void setKValue(SimpleMatrix K)
K
- A 3x3 intrinsic camera matrix.
See the class documentation for further details.initFromSKRT(double s, SimpleMatrix K, SimpleMatrix R, SimpleVector t)
public void setRValue(SimpleMatrix R)
R
- A 3x3 rotation matrix, representing the extrinsic rotation of the camera.
See the class documentation for further details.initFromSKRT(double s, SimpleMatrix K, SimpleMatrix R, SimpleVector t)
public void setTVector(SimpleVector t)
t
- A 3x1 translation vector, representing the translation of the camera.
See the class documentation for further details.initFromSKRT(double s, SimpleMatrix K, SimpleMatrix R, SimpleVector t)
public void setRtValue(SimpleMatrix Rt)
Rt
- A homogeneous 4x4 rigid motion matrix, representing the extrinsic rotation
and translation of the camera.
See the class documentation for further details.getRt()
public void setPrincipalPointValue(SimpleVector p)
p
- The principal point public void setViewingDirectionValue(double dir)
dir
- +1.0 for a camera looking in public double getS()
setSValue(double s)
public SimpleMatrix getK()
setKValue(SimpleMatrix K)
public SimpleMatrix getR()
Remark: If you want to obtain the rigid motion matrix
use createHomRigidMotionMatrix(const Matrix
Matrix<T> Rt = createHomRigidMotionMatrix(R, t);
setRValue(SimpleMatrix R)
,
getRt()
public SimpleVector getT()
setTVector(SimpleVector t)
,
getRt()
public SimpleMatrix getRt()
getR()
,
getT()
,
setRValue(SimpleMatrix R)
,
setTVector(SimpleVector t)
public SimpleVector getPrincipalPoint()
public double getViewingDirection()
public SimpleMatrix computeP()
initFromP(SimpleMatrix P)
public SimpleVector computeCameraCenter()
public SimpleVector computePrincipalAxis()
public SimpleVector computeRayDirection(SimpleVector p)
p
- A 2x1 pixel vector public void computeGLMatrices(int imgMinU, int imgMinV, int imgSizeU, int imgSizeV, double distanceNear, double distanceFar, double[] glProjectionGlVec, double[] glModelviewGlVec)
Remark: The parameters imgMinU, imgMinV, imgSizeU, and imgSizeV are needed in order to define a region of pixels which constitute an image. The image coordinates resulting from this Projection are then mapped to normalized device coordinates ([-1, 1] x [-1, 1]). These coordinates are later mapped back to window coordinates by the viewport transformation in OpenGL. Therefore, remember to set the OpenGL viewport using these four parameters!
Remark: Usually, the following OpenGL commands have to be used for setting up
OpenGL's rendering pipeline:
// instantiate projection
Nude::Geometry::Projection proj;
// ...
// set up some projection in proj by using one or more of the from...() or set...() methods
// define image viewport imgMinU, imgMinV, imgSizeU, imgSizeV and depth clipping planes n and f
// ...
// instantiate OpenGL matrices
double glProjectionGlVec[16];
double glModelviewGlVec[16];
// convert the projection into OpenGL representation
proj.computeGLMatrices(imgMinU, imgMinV, imgSizeU, imgSizeV, n, f, glProjectionGlVec, glModelviewGlVec);
// set OpenGL matrices
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(glProjectionGlVec);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(glModelviewGlVec);
// map normalized device coordinates to window coordinates
glViewPort(imgMinU, imgMinV, imgSizeU, imgSizeV);
// additionally, the following command can be executed for reversing front/back face
// definition for cameras with +z viewing direction and, therefore, enable the correct culling
glFrontFace((proj.getViewingDirection() > 0) ? GL_CW : GL_CCW);
Remark: Internally, this method returns the matrix
Warning: Mind that OpenGL uses C-style arrays in column-major order whereas the NuDeLib uses row-major matrices. However, you shouldn't bother with that since this methods returns glProjectionGlVec and glModelviewGlVec in a column-major C-style array as you set it using OpenGL's glLoadMatrixd() function.
imgMinU
- The minimum image index (in px) in the u direction (usually 0).imgMinV
- The minimum image index (in px) in the v direction (usually 0).imgSizeU
- The image width (in px) in u direction (imgSizeU = imgMaxU-imgMinU+1).imgSizeV
- The image width (in px) in v direction (imgSizeV = imgMaxV-imgMinV+1).distanceNear
- The near plane clipping coordinate (in mm). The clipping distances are measured from
the camera center to the clipping plane in mm.distanceFar
- The far plane clipping coordinate (in mm). The clipping distances are measured from
the camera center to the clipping plane in mm.glProjectionGlVec
- Return value. This has to be an already allocated(!) C-style array of
16 values, representing a 4x4 OpengGL projection matrix in column-major / OpenGL order.
It can be directly set in OpenGL in the GL_PROJECTION mode.glModelviewGlVec
- Return value. This has to be an already allocated(!) C-style array of
16 values, representing a 4x4 OpengGL modelview matrix in column-major / OpenGL order.
It can be directly set in OpenGL in the GL_MODELVIEW mode.computeGLMatrices(int imgMinU, int imgMinV, int imgSizeU, int imgSizeV, SimpleVector cubmin, SimpleVector cubmax, double[] glProjectionGlVec, double[] glModelviewGlVec)
public boolean computeGLMatrices(int imgMinU, int imgMinV, int imgSizeU, int imgSizeV, SimpleVector cubmin, SimpleVector cubmax, double[] glProjectionGlVec, double[] glModelviewGlVec)
Remark: The parameters imgMinU, imgMinV, imgSizeU, and imgSizeV are needed in order to define a region of pixels which constitute an image. The image coordinates resulting from this Projection are then mapped to normalized device coordinates ([-1, 1] x [-1, 1]). These coordinates are later mapped back to window coordinates by the viewport transformation in OpenGL. Therefore, remember to set the OpenGL viewport using these four parameters!
Remark: Usually, the following OpenGL commands have to be used for setting up
OpenGL's rendering pipeline:
// instantiate projection
Nude::Geometry::Projection proj;
// ...
// set up some projection in proj by using one or more of the from...() or set...() methods
// define image viewport imgMinU, imgMinV, imgSizeU, imgSizeV and bounding box extents cubmin and cubmax.
// ...
// instantiate OpenGL matrices
double glProjectionGlVec[16];
double glModelviewGlVec[16];
// convert the projection into OpenGL representation
proj.computeGLMatrices(imgMinU, imgMinV, imgSizeU, imgSizeV, cubmin, cubmax, glProjectionGlVec, glModelviewGlVec);
// set OpenGL matrices
glMatrixMode(GL_PROJECTION);
glLoadMatrixd(glProjectionGlVec);
glMatrixMode(GL_MODELVIEW);
glLoadMatrixd(glModelviewGlVec);
// map normalized device coordinates to window coordinates
glViewPort(imgMinU, imgMinV, imgSizeU, imgSizeV);
// additionally, the following command can be executed for reversing front/back face
// definition for cameras with +z viewing direction and, therefore, enable the correct culling
glFrontFace((proj.getViewingDirection() > 0) ? GL_CW : GL_CCW);
Warning: Mind that OpenGL uses C-style arrays in column-major order whereas the NuDeLib uses row-major matrices. However, you shouldn't bother with that since this methods returns glProjectionGlVec and glModelviewGlVec in a column-major C-style array as you set it using OpenGL's glLoadMatrixd() function.
Warning: Using this convenience method which automatically computes suitable near and far clipping planes implies that you do not further change the returned matrices, esp. the modelview matrix. Applying additional transformations in OpenGL would result in a displaced cube and therefore wrong depth clipping planes. Therefore, either apply all motions/transformations to this projection and call this method after each change or manually specify your own depth clipping planes using computeGLMatrices(final int imgMinU, final int imgMinV, final int imgSizeU, final int imgSizeV, final double n, final double f, final double[] glProjectionGlVec, final double[] glModelviewGlVec).
imgMinU
- The minimum image index (in px) in the u direction (usually 0).imgMinV
- The minimum image index (in px) in the v direction (usually 0).imgSizeU
- The image width (in px) in u direction (imgSizeU = imgMaxU-imgMinU+1).imgSizeV
- The image width (in px) in v direction (imgSizeV = imgMaxV-imgMinV+1).cubmin
- The bounding box' minimum extents (in mm).cubmax
- The bounding box' maximum extents (in mm).glProjectionGlVec
- Return value. This is an already allocated(!) C-style array of
16 values, representing a 4x4 OpengGL projection matrix in column-major /
OpenGL order. It can be directly set in OpenGL in the GL_PROJECTION mode.glModelviewGlVec
- Return value. This is an already allocated(!) C-style array of
16 values, representing a 4x4 OpengGL modelview matrix in column-major /
OpenGL order. It can be directly set in OpenGL in the GL_MODELVIEW mode.computeGLMatrices(int imgMinU, int imgMinV, int imgSizeU, int imgSizeV, double n, double f, double[] glProjectionGlVec, double[] glModelviewGlVec)
,
computeOptimalClippingDepthsForCuboid(edu.stanford.rsl.conrad.numerics.SimpleVector, edu.stanford.rsl.conrad.numerics.SimpleVector, double[])
public double computeDepth(SimpleVector v)
v
- A 3x1 vector of the given 3D point.project(edu.stanford.rsl.conrad.numerics.SimpleVector, edu.stanford.rsl.conrad.numerics.SimpleVector)
public double project(SimpleVector volumePoint, SimpleVector pixel)
volumePoint
- The 3x1 volume point in world coordinates.pixel
- The returned 2x1 image coordiante in pixels.computeDepth(edu.stanford.rsl.conrad.numerics.SimpleVector)
public boolean intersectRayWithCuboid(SimpleVector p, SimpleVector cubmin, SimpleVector cubmax, double[] distanceNearFar, SimpleVector C, SimpleVector d)
p
- A 2x1 pixel vector.cubmin
- The cuboid's minimal planes given as [min_x, min_y, min_z] in world
coordinates.cubmax
- The cuboid's box' maximal planes given as [max_x, max_y, max_z] in
world coordinates.distanceNearFar
- Return values. In case of a hit: Positive distance (in world coordinate
units) of nearest [0] and farthest [1] plane intersections.C
- Return value. The ray origin / camera center (corresponding to the internal
projection matrix) in world coordinates [ro_x, ro_y, ro_z].d
- Return value. The normalized(!) ray direction (corresponding to the given
pixel) in world coordinates [rd_x, rd_y, rd_z].public void setKFromDistancesSpacingsSizeOffset(double sourceToDetector, SimpleVector spacingUV, SimpleVector sizeUV, SimpleVector offset, double dir, double skew)
Warning: The parameters given to this method are mostly discarded since they are not essential or minimal for representing a single projection. This is why they also cannot be recovered from this object. This method is rather a convenience method for setting up this projection.
sourceToDetector
- The distance from projection / camera / X-ray source
center to the image plane / detector in world coordinates.spacingUV
- The pixel size in u- and v-direction.sizeUV
- The projection image size in u- and v-direction.offset
- The offset (in pixels) from the image center to the principal point (where the principal
ray hits the image plane orthogonally), i.e., the principal point is computed as (image center + offset).dir
- +1.0 for a camera looking in skew
- The skew parameter (usually zero).setRtFromCircularTrajectory(edu.stanford.rsl.conrad.numerics.SimpleVector, edu.stanford.rsl.conrad.numerics.SimpleVector, double, edu.stanford.rsl.conrad.numerics.SimpleVector, edu.stanford.rsl.conrad.geometry.Projection.CameraAxisDirection, edu.stanford.rsl.conrad.geometry.Projection.CameraAxisDirection, double)
public double setRtFromCircularTrajectory(SimpleVector rotationCenter, SimpleVector rotationAxis, double sourceToAxisDistance, SimpleVector centerToCameraAtZeroAngle, Projection.CameraAxisDirection uDirection, Projection.CameraAxisDirection vDirection, double rotationAngle)
Warning: The parameters given to this method are mostly discarded since they are not essential or minimal for representing a single projection. This is why they also cannot be recovered from this object. This method is rather a convenience method for setting up this projection.
rotationCenter
- The center of rotation, given as 3D point in world coordinates. (This is
usually chosen to be (0,0,0).)rotationAxis
- The rotation axis (in world coordinates) for a circular acquisition
trajectory (where the last projection's angular value is bigger than the first one's.)
(This is usually chosen to be (0,0,1).)sourceToAxisDistance
- The radius of the camera rotation, i.e. the distance from the camera /
X-ray source to the iso center.centerToCameraAtZeroAngle
- The direction from the center of rotation to the camera position
at zero angle. This direction vector can have any length but zero. Its normalized version
is used together with the sourceToAxisDistance for translating the camera to its zero angle
position. Since the zero angle position has to be on the circular trajectory defined by
the rotationAxis (and the sourceToAxisDistance), centerToCameraAtZeroAngle has to be
perpendicular to rotationAxis. (This is usually chosen to be (1,0,0).)uDirection
- Sets the camera's u axis in terms of the direction of motion of the detector
(for increasing angles) and the rotation axis.vDirection
- Sets the camera's v axis in terms of the direction of motion of the detector
(for increasing angles) and the rotation axis.rotationAngle
- The angle of rotation (away from the zero position) for this projection.TODO: Move this method to ProjectionSeries, taking an array of angles and generating the series
of Projections?
public double[] computeSourceToDetectorDistance(SimpleVector spacingUV)
Projection
class only stores the minimal information needed for establishing
world to pixel correspondences. It therefore only know the focal length in pixels
(stored as the first two diagonal entries of the K matrix). Computing the source-to-detector
distance requires knowledge about the pixel size. Since there are focal length entries in K
that could be used for computing the source-to-detector distance, this method returns two
result values. They should, theoretically, be equal. This check is left to the caller of this method.spacingUV
- Given pixel sizes in u- and v-direction.public SimpleVector computeOffset(SimpleVector sizeUV)
sizeUV
- Projection image size in u- and v-direction in pixels.public java.lang.String toString()
toString
in class java.lang.Object
public void setPMatrixSerialization(java.lang.String projectionMatrix)
projectionMatrix
- String representation of the projection matrix to de-serialize.public java.lang.String getPMatrixSerialization()
public SimpleMatrix getRTKinv()