NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
itk::Ray< TInputImage, TCoordRep > Class Template Reference

Class to project a ray through a 3D volume. More...

Public Types

typedef itk::Point< TCoordRep, 3 > InputPointType
 
typedef itk::Point< TCoordRep, 2 > OutputPointType
 
typedef TInputImage InputImageType
 
typedef InputImageType::PixelType PixelType
 
typedef InputImageType::IndexType IndexType
 
typedef InputImageType::SizeType SizeType
 
typedef
InputImageType::OffsetValueType 
OffsetValueType
 
typedef itk::Matrix< double, 4, 4 > ProjectionMatrixType
 

Public Member Functions

 Ray ()
 Constructor. More...
 
virtual ~Ray ()
 Destructor. More...
 
void SetProjectionMatrix (const ProjectionMatrixType input)
 Set the combined affine and projection matrix. More...
 
void SetImage (const InputImageType *input)
 
bool SetRay (OutputPointType RayPosn)
 
void SetProjectionResolution2Dmm (double xRes, double yRes)
 
double GetCurrentIntensity (void) const
 Return the interpolated intensity of the current ray point. More...
 
double GetRayPointSpacing (void) const
 Return the ray point spacing in mm. More...
 
int GetNumberOfRayPoints (void)
 Return the number of points on the ray. More...
 
void GetBilinearCoefficients (double &y, double &z) const
 Get the the bilinear coefficient for the current ray point. More...
 
PixelType ** GetRayIntersectionVoxels (void)
 
const intGetRayIntersectionVoxelIndex (void) const
 Get the voxel index of the intersection. More...
 
int GetTraversalDirection (void)
 Get the traversal direction. More...
 
bool Integrate (double &integral)
 Integrate the interpolated intensities along the ray and return the result. More...
 
bool IntegrateAboveThreshold (double &integral, double threshold)
 Integrate the interpolated intensities above a given threshold, along the ray and return the result. More...
 
bool IncrementRayVoxelIntensities (double increment)
 Increment each of the intensities of the 4 planar voxels surrounding every point along the ray using bilinear interpolation. More...
 
void IncrementIntensities (double increment)
 Increment each of the intensities of the 4 planar voxels surrounding the current ray point using bilinear interpolation. More...
 
void IncrementIntensities (void)
 Increment each of the intensities of the 4 planar voxels surrounding the current ray point by one. More...
 
void Reset (void)
 Reset the iterator to the start of the ray. More...
 
bool NextPoint (void)
 Step along the ray. More...
 

Protected Types

enum  TraversalDirection {
  UNDEFINED_DIRECTION =0, TRANSVERSE_IN_X, TRANSVERSE_IN_Y, TRANSVERSE_IN_Z,
  LAST_DIRECTION
}
 

Protected Member Functions

void ZeroState ()
 Set the initial zero state of the object. More...
 
void Initialise (void)
 Initialise the object. More...
 
void EndPointsInVoxels (void)
 Calculate the endpoint coordinats of the ray in voxels. More...
 
void CalcDirnVector (void)
 
bool AdjustRayLength (void)
 
void InitialiseVoxelPointers (void)
 
void IncrementVoxelPointers (void)
 Increment the voxel pointers surrounding the current point on the ray. More...
 
void RecordVolumeDimensions (void)
 Record volume dimensions and resolution. More...
 
void DefineCorners (void)
 Define the corners of the volume. More...
 
void CalcPlanesAndCorners (void)
 Calculate the planes which define the volume. More...
 
bool CalcRayIntercepts (void)
 Calculate the ray intercepts with the volume. More...
 
void Line3D (double x2D, double y2D, double r[3], double u[3])
 Calculate the equation of the ray throught the volume. More...
 

Protected Attributes

const InputImageTypem_Image
 
bool m_ValidRay
 Flag indicating whether the current ray is valid. More...
 
double m_RayPosition2Dmm [2]
 The ray intercept 2D coordinate. More...
 
double m_ProjectionResolution2Dmm [2]
 The resolution of the 2D projection image. More...
 
double m_RayVoxelStartPosition [3]
 The start position of the ray in voxels. More...
 
double m_RayVoxelEndPosition [3]
 The end coordinate of the ray in voxels. More...
 
double m_Position3Dvox [3]
 The current coordinate on the ray in voxels. More...
 
double m_VoxelIncrement [3]
 
TraversalDirection m_TraversalDirection
 The direction in which the ray is incremented thorough the volume (x, y or z). More...
 
int m_TotalRayVoxelPlanes
 The total number of planes of voxels traversed by the ray. More...
 
int m_NumVoxelPlanesTraversed
 The current number of planes of voxels traversed by the ray. More...
 
PixelTypem_RayIntersectionVoxels [4]
 Pointers to the current four voxels surrounding the ray's trajectory. More...
 
int m_RayIntersectionVoxelIndex [3]
 
int m_NumberOfVoxelsInX
 The dimension in voxels of the 3D volume in along the x axis. More...
 
int m_NumberOfVoxelsInY
 The dimension in voxels of the 3D volume in along the y axis. More...
 
int m_NumberOfVoxelsInZ
 The dimension in voxels of the 3D volume in along the z axis. More...
 
double m_VoxelDimensionInX
 Voxel dimension in x. More...
 
double m_VoxelDimensionInY
 Voxel dimension in y. More...
 
double m_VoxelDimensionInZ
 Voxel dimension in z. More...
 
double m_RayStartCoordInMM [3]
 The coordinate of the point at which the ray enters the volume in mm. More...
 
double m_RayEndCoordInMM [3]
 The coordinate of the point at which the ray exits the volume in mm. More...
 
double m_BoundingPlane [6][4]
 Planes which define the boundary of the volume in mm (six planes and four parameters: Ax+By+Cz+D). More...
 
double m_BoundingCorner [8][3]
 The eight corners of the volume (x,y,z coordinates for each). More...
 
double m_CurrentRayPositionInMM [3]
 The position of the ray in 3D. More...
 
double m_RayDirectionInMM [3]
 The direction of the ray. More...
 
ProjectionMatrixType m_ProjectionMatrix
 The combined affine and perspective transformation. More...
 

Detailed Description

template<class TInputImage, class TCoordRep = double>
class itk::Ray< TInputImage, TCoordRep >

Class to project a ray through a 3D volume.

Member Typedef Documentation

template<class TInputImage , class TCoordRep = double>
typedef InputImageType::IndexType itk::Ray< TInputImage, TCoordRep >::IndexType
template<class TInputImage , class TCoordRep = double>
typedef TInputImage itk::Ray< TInputImage, TCoordRep >::InputImageType
template<class TInputImage , class TCoordRep = double>
typedef itk::Point<TCoordRep, 3> itk::Ray< TInputImage, TCoordRep >::InputPointType
template<class TInputImage , class TCoordRep = double>
typedef InputImageType::OffsetValueType itk::Ray< TInputImage, TCoordRep >::OffsetValueType
template<class TInputImage , class TCoordRep = double>
typedef itk::Point<TCoordRep, 2> itk::Ray< TInputImage, TCoordRep >::OutputPointType
template<class TInputImage , class TCoordRep = double>
typedef InputImageType::PixelType itk::Ray< TInputImage, TCoordRep >::PixelType
template<class TInputImage , class TCoordRep = double>
typedef itk::Matrix<double, 4, 4> itk::Ray< TInputImage, TCoordRep >::ProjectionMatrixType

The combined affine and perspective projection matrix type. NB: defined as a square matrix because ITK does not appear to support matrix multiplication of non square matrices.

template<class TInputImage , class TCoordRep = double>
typedef InputImageType::SizeType itk::Ray< TInputImage, TCoordRep >::SizeType

Member Enumeration Documentation

template<class TInputImage , class TCoordRep = double>
enum itk::Ray::TraversalDirection
protected

The ray is traversed by stepping in the axial direction that enables the greatest number of planes in the volume to be intercepted.

Enumerator
UNDEFINED_DIRECTION 

Undefined.

TRANSVERSE_IN_X 

x

TRANSVERSE_IN_Y 

y

TRANSVERSE_IN_Z 

z

LAST_DIRECTION 

Constructor & Destructor Documentation

template<class TInputImage , class TCoordRep = double>
itk::Ray< TInputImage, TCoordRep >::Ray ( )

Constructor.

template<class TInputImage , class TCoordRep = double>
virtual itk::Ray< TInputImage, TCoordRep >::~Ray ( )
inlinevirtual

Destructor.

Member Function Documentation

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::AdjustRayLength ( void  )
protected

Reduce the length of the ray until both start and end coordinates lie inside the volume.

Returns
True if a valid ray has been, false otherwise.
template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::CalcDirnVector ( void  )
protected

Calculate the incremental direction vector in voxels, 'dVoxel', required to traverse the ray.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::CalcPlanesAndCorners ( void  )
protected

Calculate the planes which define the volume.

Member function to calculate the equations of the planes of 4 of the sides of the volume, calculate the positions of the 8 corners of the volume in mm in World, also calculate the values of the slopes of the lines which go to make up the volume( defined as lines in cube x,y,z dirn and then each of these lines has a slope in the world x,y,z dirn [3]) and finally also to return the length of the sides of the lines in mm.

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::CalcRayIntercepts ( void  )
protected

Calculate the ray intercepts with the volume.

See where the ray cuts the volume, check that truncation does not occur, if not, then start ray where it first intercepts the volume and set x_max to be where it leaves the volume.

Returns
True if a valid ray has been specified, false otherwise.
template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::DefineCorners ( void  )
protected

Define the corners of the volume.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::EndPointsInVoxels ( void  )
protected

Calculate the endpoint coordinats of the ray in voxels.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::GetBilinearCoefficients ( double &  y,
double &  z 
) const

Get the the bilinear coefficient for the current ray point.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::GetCurrentIntensity ( void  ) const

Return the interpolated intensity of the current ray point.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::GetNumberOfRayPoints ( void  )
inline

Return the number of points on the ray.

template<class TInputImage , class TCoordRep = double>
const int* itk::Ray< TInputImage, TCoordRep >::GetRayIntersectionVoxelIndex ( void  ) const
inline

Get the voxel index of the intersection.

template<class TInputImage , class TCoordRep = double>
PixelType** itk::Ray< TInputImage, TCoordRep >::GetRayIntersectionVoxels ( void  )
inline
template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::GetRayPointSpacing ( void  ) const
inline

Return the ray point spacing in mm.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::GetTraversalDirection ( void  )
inline

Get the traversal direction.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::IncrementIntensities ( double  increment)

Increment each of the intensities of the 4 planar voxels surrounding the current ray point using bilinear interpolation.

increment Intensity increment for each of the current 4 voxels

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::IncrementIntensities ( void  )

Increment each of the intensities of the 4 planar voxels surrounding the current ray point by one.

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::IncrementRayVoxelIntensities ( double  increment)

Increment each of the intensities of the 4 planar voxels surrounding every point along the ray using bilinear interpolation.

increment Intensity increment for each of the current 4 voxels

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::IncrementVoxelPointers ( void  )
protected

Increment the voxel pointers surrounding the current point on the ray.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::Initialise ( void  )
protected

Initialise the object.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::InitialiseVoxelPointers ( void  )
protected

Obtain pointers to the four voxels surrounding the point where the ray enters the volume.

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::Integrate ( double &  integral)
inline

Integrate the interpolated intensities along the ray and return the result.

This routine can be called after instantiating the ray and calling SetProjectionCoord2D() or Reset(). It may then be called as many times thereafter for different 2D projection coordinates.

Parameters
integralThe integrated intensities along the ray.
Returns
True if a valid ray was specified.
template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::IntegrateAboveThreshold ( double &  integral,
double  threshold 
)

Integrate the interpolated intensities above a given threshold, along the ray and return the result.

This routine can be called after instantiating the ray and calling SetProjectionCoord2D() or Reset(). It may then be called as many times thereafter for different 2D projection coordinates.

Parameters
integralThe integrated intensities along the ray.
thresholdThe integration threshold [default value: 0]
Returns
True if a valid ray was specified.
template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::Line3D ( double  x2D,
double  y2D,
double  r[3],
double  u[3] 
)
protected

Calculate the equation of the ray throught the volume.

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::NextPoint ( void  )

Step along the ray.

This routine can be called iteratively to step along a given ray. To specify a new ray call: 'SetRay()' first. To re-traverse the current ray call: 'Reset()'.

Returns
False if there are no more points on the ray.
template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::RecordVolumeDimensions ( void  )
protected

Record volume dimensions and resolution.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::Reset ( void  )

Reset the iterator to the start of the ray.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::SetImage ( const InputImageType input)
inline

Set the image class

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::SetProjectionMatrix ( const ProjectionMatrixType  input)
inline

Set the combined affine and projection matrix.

template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::SetProjectionResolution2Dmm ( double  xRes,
double  yRes 
)
inline

Set the resolution of the 2D projection image. This is used to normalise the projected intensities to ensure the back-projected 3D image will have similar sum of intensities to the original volume.

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::SetRay ( OutputPointType  RayPosn)

Initialise the ray using the position of a point on the 2D projection image

Parameters
RayPosnThe position of the ray in 2D (mm).
Returns
True if this is a valid ray.
template<class TInputImage , class TCoordRep = double>
void itk::Ray< TInputImage, TCoordRep >::ZeroState ( )
protected

Set the initial zero state of the object.

Member Data Documentation

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_BoundingCorner[8][3]
protected

The eight corners of the volume (x,y,z coordinates for each).

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_BoundingPlane[6][4]
protected

Planes which define the boundary of the volume in mm (six planes and four parameters: Ax+By+Cz+D).

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_CurrentRayPositionInMM[3]
protected

The position of the ray in 3D.

template<class TInputImage , class TCoordRep = double>
const InputImageType* itk::Ray< TInputImage, TCoordRep >::m_Image
protected
template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_NumberOfVoxelsInX
protected

The dimension in voxels of the 3D volume in along the x axis.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_NumberOfVoxelsInY
protected

The dimension in voxels of the 3D volume in along the y axis.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_NumberOfVoxelsInZ
protected

The dimension in voxels of the 3D volume in along the z axis.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_NumVoxelPlanesTraversed
protected

The current number of planes of voxels traversed by the ray.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_Position3Dvox[3]
protected

The current coordinate on the ray in voxels.

NB. Two of the components of this coordinate (i.e. those lying within the planes of voxels being traversed) will be shifted by half a voxel. This enables indices of the neighbouring voxels within the plane to be determined by simply casting to 'int' and optionally adding 1.

template<class TInputImage , class TCoordRep = double>
ProjectionMatrixType itk::Ray< TInputImage, TCoordRep >::m_ProjectionMatrix
protected

The combined affine and perspective transformation.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_ProjectionResolution2Dmm[2]
protected

The resolution of the 2D projection image.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayDirectionInMM[3]
protected

The direction of the ray.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayEndCoordInMM[3]
protected

The coordinate of the point at which the ray exits the volume in mm.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_RayIntersectionVoxelIndex[3]
protected

The voxel coordinate of the bottom-left voxel of the current four voxels surrounding the ray's trajectory.

template<class TInputImage , class TCoordRep = double>
PixelType* itk::Ray< TInputImage, TCoordRep >::m_RayIntersectionVoxels[4]
protected

Pointers to the current four voxels surrounding the ray's trajectory.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayPosition2Dmm[2]
protected

The ray intercept 2D coordinate.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayStartCoordInMM[3]
protected

The coordinate of the point at which the ray enters the volume in mm.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayVoxelEndPosition[3]
protected

The end coordinate of the ray in voxels.

NB. Two of the components of this coordinate (i.e. those lying within the planes of voxels being traversed) will be shifted by half a voxel. This enables indices of the neighbouring voxels within the plane to be determined by simply casting to 'int' and optionally adding 1.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_RayVoxelStartPosition[3]
protected

The start position of the ray in voxels.

NB. Two of the components of this coordinate (i.e. those lying within the planes of voxels being traversed) will be shifted by half a voxel. This enables indices of the neighbouring voxels within the plane to be determined by simply casting to 'int' and optionally adding 1.

template<class TInputImage , class TCoordRep = double>
int itk::Ray< TInputImage, TCoordRep >::m_TotalRayVoxelPlanes
protected

The total number of planes of voxels traversed by the ray.

template<class TInputImage , class TCoordRep = double>
TraversalDirection itk::Ray< TInputImage, TCoordRep >::m_TraversalDirection
protected

The direction in which the ray is incremented thorough the volume (x, y or z).

template<class TInputImage , class TCoordRep = double>
bool itk::Ray< TInputImage, TCoordRep >::m_ValidRay
protected

Flag indicating whether the current ray is valid.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_VoxelDimensionInX
protected

Voxel dimension in x.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_VoxelDimensionInY
protected

Voxel dimension in y.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_VoxelDimensionInZ
protected

Voxel dimension in z.

template<class TInputImage , class TCoordRep = double>
double itk::Ray< TInputImage, TCoordRep >::m_VoxelIncrement[3]
protected

The incremental direction vector of the ray in voxels.


The documentation for this class was generated from the following file: