Class GeometryOfSlice

  • Direct Known Subclasses:
    GeometryOfSliceFromAttributeList

    public class GeometryOfSlice
    extends java.lang.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.

    • Constructor Summary

      Constructors 
      Constructor Description
      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

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean areSlicesParallel​(GeometryOfSlice slice1, GeometryOfSlice slice2)
      Determine if two slices are parallel.
      protected void findMaxComponents()  
      javax.vecmath.Vector3d getColumn()
      Get the column direction.
      double[] getColumnArray()
      Get the column direction.
      java.lang.String getColumnOrientation()
      Get the letter representation of the orientation of the columns of this slice.
      java.lang.String getColumnOrientation​(boolean quadruped)
      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 java.lang.String getOrientation​(double[] orientation)
      Get the letter representation of the orientation of a vector.
      static java.lang.String getOrientation​(double[] orientation, boolean quadruped)
      Get the letter representation of the orientation of a vector.
      javax.vecmath.Vector3d getRow()
      Get the row direction.
      double[] getRowArray()
      Get the row direction.
      java.lang.String getRowOrientation()
      Get the letter representation of the orientation of the rows of this slice.
      java.lang.String getRowOrientation​(boolean quadruped)
      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​(double[] location)
      Is an arbitrary point in the DICOM 3D coordinate space within the plane of the image.
      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()  
      java.lang.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
      • R

        protected int R
      • C

        protected int C
    • 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
      • findMaxComponents

        protected final void findMaxComponents()
      • 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).

        Parameters:
        point - the point
        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.

        Parameters:
        point - the point
        Returns:
        true if within the plane of the image
      • isPointInSlicePlane

        public final boolean isPointInSlicePlane​(double[] location)

        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.

        Parameters:
        location - the point
        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 java.lang.String toString()

        Get a human-readable rendering of the geometry.

        Overrides:
        toString in class java.lang.Object
        Returns:
        the string rendering of the geometry
      • getOrientation

        public static final java.lang.String getOrientation​(double[] orientation,
                                                            boolean quadruped)

        Get the letter representation of the orientation of a vector.

        For bipeds, L or R, A or P, H or F.

        For quadrupeds, Le or Rt, V or D, Cr or Cd (with lower case; use toUpperCase() to produce valid CodeString for PatientOrientation).

        Parameters:
        orientation - the orientation
        quadruped - true if subject is a quadruped rather than a biped
        Returns:
        a string rendering of the orientation, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails
      • getOrientation

        public static final java.lang.String getOrientation​(double[] orientation)

        Get the letter representation of the orientation of a vector.

        Assumes a biped rather than a quadruped, so returns L or R, A or P, H or F.

        Parameters:
        orientation - the orientation
        Returns:
        a string rendering of the orientation, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails
      • getRowOrientation

        public final java.lang.String getRowOrientation​(boolean quadruped)

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

        For bipeds, L or R, A or P, H or F.

        For quadrupeds, Le or Rt, V or D, Cr or Cd (with lower case; use toUpperCase() to produce valid CodeString for PatientOrientation).

        Parameters:
        quadruped - true if subject is a quadruped rather than a biped
        Returns:
        a string rendering of the row orientation, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails
      • getColumnOrientation

        public final java.lang.String getColumnOrientation​(boolean quadruped)

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

        For bipeds, L or R, A or P, H or F.

        For quadrupeds, Le or Rt, V or D, Cr or Cd (with lower case; use toUpperCase() to produce valid CodeString for PatientOrientation).

        Parameters:
        quadruped - true if subject is a quadruped rather than a biped
        Returns:
        a string rendering of the column orientation, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails
      • getRowOrientation

        public final java.lang.String getRowOrientation()

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

        Assumes a biped rather than a quadruped, so returns L or R, A or P, H or F.

        Returns:
        a string rendering of the row orientation, more than one letter if oblique to the orthogonal axes, or empty string (not null) if fails
      • getColumnOrientation

        public final java.lang.String getColumnOrientation()

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

        Assumes a biped rather than a quadruped, so returns L or R, A or P, H or F.

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