com.pixelmed.geometry
Class GeometryOfSlice

java.lang.Object
  extended by com.pixelmed.geometry.GeometryOfSlice
Direct Known Subclasses:
GeometryOfSliceFromAttributeList

public class GeometryOfSlice
extends Object

A class to describe the spatial geometry of a single cross-sectional image slice.

The 3D coordinate space used is the DICOM coordinate space, which is LPH+, that is, the x-axis is increasing to the left hand side of the patient, the y-axis is increasing to the posterior side of the patient, and the z-axis is increasing toward the head of the patient.


Field Summary
protected  javax.vecmath.Vector3d column
           
protected  double[] columnArray
           
protected  javax.vecmath.Tuple3d dimensions
           
protected  javax.vecmath.Vector3d normal
           
protected  double[] normalArray
           
protected  javax.vecmath.Vector3d row
           
protected  double[] rowArray
           
protected  double sliceThickness
           
protected  javax.vecmath.Point3d tlhc
           
protected  double[] tlhcArray
           
protected  javax.vecmath.Tuple3d voxelSpacing
           
protected  double[] voxelSpacingArray
           
 
Constructor Summary
GeometryOfSlice()
          Construct an empty geometry.
GeometryOfSlice(double[] rowArray, double[] columnArray, double[] tlhcArray, double[] voxelSpacingArray, double sliceThickness, double[] dimensions)
          Construct the geometry.
GeometryOfSlice(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column, javax.vecmath.Point3d tlhc, javax.vecmath.Tuple3d voxelSpacing, double sliceThickness, javax.vecmath.Tuple3d dimensions)
          Construct the geometry.
 
Method Summary
static boolean areSlicesParallel(GeometryOfSlice slice1, GeometryOfSlice slice2)
          Determine if two slices are parallel.
 javax.vecmath.Vector3d getColumn()
          Get the column direction.
 double[] getColumnArray()
          Get the column direction.
 String getColumnOrientation()
          Get the letter representation of the orientation of the columns of this slice.
 javax.vecmath.Tuple3d getDimensions()
          Get the dimensions of the voxel.
 double getDistanceAlongNormalFromOrigin()
          Given the present geometry, determine the distance along the normal to the plane of the slice of the TLHC of the image from the origin of the coordinate space (0,0,0).
 double getDistanceAlongNormalFromOrigin(javax.vecmath.Point3d point)
          Given the present geometry, determine the distance along the normal to the plane of the slice of an arbitrary point (not necessarily in the plane of the image) from the origin of the coordinate space (0,0,0).
 javax.vecmath.Vector3d getNormal()
          Get the normal direction.
 double[] getNormalArray()
          Get the normal direction.
static String getOrientation(double[] orientation)
          Get the letter representation of the orientation of a vector.
 javax.vecmath.Vector3d getRow()
          Get the row direction.
 double[] getRowArray()
          Get the row direction.
 String getRowOrientation()
          Get the letter representation of the orientation of the rows of this slice.
 double getSliceThickness()
          Get the spacing between centers of the voxel in three dimension.
 javax.vecmath.Point3d getTLHC()
          Get the position of the top left hand corner.
 double[] getTLHCArray()
          Get the position of the top left hand corner.
 javax.vecmath.Tuple3d getVoxelSpacing()
          Get the spacing between centers of the voxel in three dimension.
 double[] getVoxelSpacingArray()
          Get the spacing between centers of the voxel in three dimension.
 boolean isPointInSlicePlane(javax.vecmath.Point3d point)
          Is an arbitrary point in the DICOM 3D coordinate space within the plane of the image.
 double[] lookupImageCoordinate(double[] location)
          Given the present geometry, look up the location of a point specified in x,y and z coordinates of the point in the DICOM 3D coordinate space, and return the image coordinates (column and row offset).
 void lookupImageCoordinate(double[] offsets, double[] location)
          Given the present geometry, look up the location of a point specified in x,y and z coordinates of the point in the DICOM 3D coordinate space, and return the image coordinates (column and row offset).
 void lookupImageCoordinate(double[] location, double column, double row)
          Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.
 void lookupImageCoordinate(double[] location, int column, int row)
          Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.
 double[] lookupImageCoordinate(double column, double row)
          Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.
 double[] lookupImageCoordinate(int column, int row)
          Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.
protected  void makeNormal()
           
 String toString()
          Get a human-readable rendering of the geometry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

rowArray

protected double[] rowArray

row

protected javax.vecmath.Vector3d row

columnArray

protected double[] columnArray

column

protected javax.vecmath.Vector3d column

tlhc

protected javax.vecmath.Point3d tlhc

tlhcArray

protected double[] tlhcArray

voxelSpacing

protected javax.vecmath.Tuple3d voxelSpacing

voxelSpacingArray

protected double[] voxelSpacingArray

sliceThickness

protected double sliceThickness

dimensions

protected javax.vecmath.Tuple3d dimensions

normal

protected javax.vecmath.Vector3d normal

normalArray

protected double[] normalArray
Constructor Detail

GeometryOfSlice

public GeometryOfSlice()

Construct an empty geometry.


GeometryOfSlice

public GeometryOfSlice(javax.vecmath.Vector3d row,
                       javax.vecmath.Vector3d column,
                       javax.vecmath.Point3d tlhc,
                       javax.vecmath.Tuple3d voxelSpacing,
                       double sliceThickness,
                       javax.vecmath.Tuple3d dimensions)

Construct the geometry.

Parameters:
row - the direction of the row as X, Y and Z components (direction cosines, unit vector) LPH+
column - the direction of the column as X, Y and Z components (direction cosines, unit vector) LPH+
tlhc - the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+
voxelSpacing - the row and column spacing and, if a volume, the slice interval (spacing between the centers of parallel slices) in mm
sliceThickness - the slice thickness in mm
dimensions - the row and column dimensions and 1 for the third dimension

GeometryOfSlice

public GeometryOfSlice(double[] rowArray,
                       double[] columnArray,
                       double[] tlhcArray,
                       double[] voxelSpacingArray,
                       double sliceThickness,
                       double[] dimensions)

Construct the geometry.

Parameters:
rowArray - the direction of the row as X, Y and Z components (direction cosines, unit vector) LPH+
columnArray - the direction of the column as X, Y and Z components (direction cosines, unit vector) LPH+
tlhcArray - the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+
voxelSpacingArray - the row and column spacing and, if a volume, the slice interval (spacing between the centers of parallel slices) in mm
sliceThickness - the slice thickness in mm
dimensions - the row and column dimensions and 1 for the third dimension
Method Detail

makeNormal

protected final void makeNormal()

getRow

public final javax.vecmath.Vector3d getRow()

Get the row direction.

Returns:
the direction of the row as X, Y and Z components (direction cosines, unit vector) LPH+

getRowArray

public final double[] getRowArray()

Get the row direction.

Returns:
the direction of the row as X, Y and Z components (direction cosines, unit vector) LPH+

getColumn

public final javax.vecmath.Vector3d getColumn()

Get the column direction.

Returns:
the direction of the column as X, Y and Z components (direction cosines, unit vector) LPH+

getColumnArray

public final double[] getColumnArray()

Get the column direction.

Returns:
the direction of the column as X, Y and Z components (direction cosines, unit vector) LPH+

getNormal

public final javax.vecmath.Vector3d getNormal()

Get the normal direction.

Returns:
the direction of the normal to the plane of the slices, as X, Y and Z components (direction cosines, unit vector) LPH+

getNormalArray

public final double[] getNormalArray()

Get the normal direction.

Returns:
the direction of the normal to the plane of the slices, as X, Y and Z components (direction cosines, unit vector) LPH+

getTLHC

public final javax.vecmath.Point3d getTLHC()

Get the position of the top left hand corner.

Returns:
the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+

getTLHCArray

public final double[] getTLHCArray()

Get the position of the top left hand corner.

Returns:
the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+

getVoxelSpacing

public final javax.vecmath.Tuple3d getVoxelSpacing()

Get the spacing between centers of the voxel in three dimension.

Returns:
the row and column spacing and, if a volume, the slice interval (spacing between the centers of parallel slices) in mm

getVoxelSpacingArray

public final double[] getVoxelSpacingArray()

Get the spacing between centers of the voxel in three dimension.

Returns:
the row and column spacing and, if a volume, the slice interval (spacing between the centers of parallel slices) in mm

getSliceThickness

public final double getSliceThickness()

Get the spacing between centers of the voxel in three dimension.

Returns:
the slice thickness in mm

getDimensions

public final javax.vecmath.Tuple3d getDimensions()

Get the dimensions of the voxel.

Returns:
the row and column dimensions and 1 for the third dimension

lookupImageCoordinate

public final double[] lookupImageCoordinate(int column,
                                            int row)

Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.

Parameters:
column - the offset along the column from the top left hand corner, zero being no offset
row - the offset along the row from the top left hand corner, zero being no offset
Returns:
the x, y and z location in 3D space

lookupImageCoordinate

public final void lookupImageCoordinate(double[] location,
                                        int column,
                                        int row)

Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.

Parameters:
location - an array in which to return the x, y and z location in 3D space
column - the offset along the column from the top left hand corner, zero being no offset
row - the offset along the row from the top left hand corner, zero being no offset

lookupImageCoordinate

public final double[] lookupImageCoordinate(double column,
                                            double row)

Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.

Parameters:
column - the offset along the column from the top left hand corner, zero being no offset
row - the offset along the row from the top left hand corner, zero being no offset
Returns:
the x, y and z location in 3D space

lookupImageCoordinate

public final void lookupImageCoordinate(double[] location,
                                        double column,
                                        double row)

Given the present geometry, look up the location of a point specified in image coordinates (column and row offset) and return the x,y and z coordinates of the point in the DICOM 3D coordinate space.

Parameters:
location - an array in which to return the x, y and z location in 3D space
column - the offset along the column from the top left hand corner, zero being no offset
row - the offset along the row from the top left hand corner, zero being no offset

lookupImageCoordinate

public final double[] lookupImageCoordinate(double[] location)

Given the present geometry, look up the location of a point specified in x,y and z coordinates of the point in the DICOM 3D coordinate space, and return the image coordinates (column and row offset).

Parameters:
location - the x, y and z location in 3D space
Returns:
the column and row offsets from the top left hand corner of the image

lookupImageCoordinate

public final void lookupImageCoordinate(double[] offsets,
                                        double[] location)

Given the present geometry, look up the location of a point specified in x,y and z coordinates of the point in the DICOM 3D coordinate space, and return the image coordinates (column and row offset).

Parameters:
offsets - an array in which to return the column and row offsets from the top left hand corner of the image
location - the x, y and z location in 3D space

getDistanceAlongNormalFromOrigin

public final double getDistanceAlongNormalFromOrigin(javax.vecmath.Point3d point)

Given the present geometry, determine the distance along the normal to the plane of the slice of an arbitrary point (not necessarily in the plane of the image) from the origin of the coordinate space (0,0,0).

Returns:
the distance of the point from the origin along the normal axis

getDistanceAlongNormalFromOrigin

public final double getDistanceAlongNormalFromOrigin()

Given the present geometry, determine the distance along the normal to the plane of the slice of the TLHC of the image from the origin of the coordinate space (0,0,0).

Returns:
the distance of the TLHC from the origin along the normal axis

isPointInSlicePlane

public final boolean isPointInSlicePlane(javax.vecmath.Point3d point)

Is an arbitrary point in the DICOM 3D coordinate space within the plane of the image.

Slice thickness is not considered, only floating point rounding precision tolerance is permitted.

Returns:
true if within the plane of the image

areSlicesParallel

public static final boolean areSlicesParallel(GeometryOfSlice slice1,
                                              GeometryOfSlice slice2)

Determine if two slices are parallel.

Parameters:
slice1 - the geometry of one slice
slice2 - the geometry of the other slice
Returns:
true if slices are parallel

toString

public final String toString()

Get a human-readable rendering of the geometry.

Overrides:
toString in class Object
Returns:
the string rendering of the geometry

getOrientation

public static final String getOrientation(double[] orientation)

Get the letter representation of the orientation of a vector.

Returns:
a string rendering of the orientation, L or R, A or P, H or F, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails

getRowOrientation

public final String getRowOrientation()

Get the letter representation of the orientation of the rows of this slice.

Returns:
a string rendering of the row orientation, L or R, A or P, H or F, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails

getColumnOrientation

public final String getColumnOrientation()

Get the letter representation of the orientation of the columns of this slice.

Returns:
a string rendering of the column orientation, L or R, A or P, H or F, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails