Class LocalizerPoster

java.lang.Object
com.pixelmed.geometry.LocalizerPoster

public abstract class LocalizerPoster extends Object

An abstract class that provides the basis for posting the position of specified slices and volumes on (usually orthogonal) localizer images.

This base class provides the interface, common storage and various utility methods, and specific methods of performing the localization operation are performed by concrete sub-classes, instantiated through a factory class.

Typically this would b used as follows, to get outlines in the form of a vector of shapes whose coordinates are those of the localizer image:

GeometryOfSlice localizerGeometry = new GeometryOfSliceFromAttributeList(localizerAttributeList);
GeometryOfSlice postImageGeometry = new GeometryOfSliceFromAttributeList(postImageAttributeList);
LocalizerPoster localizerPoster = LocalizerPosterFactory.getLocalizerPoster(false,false);
localizerPoster.setLocalizerGeometry(localizerGeometry);
Vector shapes = localizerPoster.getOutlineOnLocalizerForThisGeometry(postImageGeometry);
 
See Also:
  • Field Details

    • localizerRow

      protected javax.vecmath.Vector3d localizerRow
    • localizerColumn

      protected javax.vecmath.Vector3d localizerColumn
    • localizerNormal

      protected javax.vecmath.Vector3d localizerNormal
    • localizerTLHC

      protected javax.vecmath.Point3d localizerTLHC
    • localizerVoxelSpacing

      protected javax.vecmath.Tuple3d localizerVoxelSpacing
    • localizerVoxelSpacingArray

      protected double[] localizerVoxelSpacingArray
    • localizerDimensions

      protected javax.vecmath.Tuple3d localizerDimensions
    • localizerDimensionsArray

      protected double[] localizerDimensionsArray
    • rotateIntoLocalizerSpace

      protected javax.vecmath.Matrix3d rotateIntoLocalizerSpace
  • Method Details

    • validateDirectionCosines

      public static void validateDirectionCosines(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column) throws IllegalArgumentException

      Check that the row and column vectors are unit vectors and are orthogonal.

      Parameters:
      row - the row direction cosines
      column - the column direction cosines
      Throws:
      IllegalArgumentException - thrown if not
    • validateDirectionCosines

      public static void validateDirectionCosines(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column, javax.vecmath.Vector3d normal) throws IllegalArgumentException

      Check that the row and column and slice direction vectors are unit vectors and are orthogonal.

      Parameters:
      row - the row direction cosines
      column - the column direction cosines
      normal - the normal to the row and column plane (the slice direction)
      Throws:
      IllegalArgumentException - thrown if not
    • getCornersOfSourceRectangleInSourceSpace

      public static javax.vecmath.Point3d[] getCornersOfSourceRectangleInSourceSpace(GeometryOfSlice g)

      Get the corners of a slice in the 3D coordinate space of that slice.

      Parameters:
      g - the geometry of a slice
      Returns:
      an array of four points that are the tlhc,trhc, brhc, blhc of the slice
    • getCornersOfSourceRectangleInSourceSpace

      public static javax.vecmath.Point3d[] getCornersOfSourceRectangleInSourceSpace(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column, javax.vecmath.Point3d originalTLHC, javax.vecmath.Tuple3d voxelSpacing, javax.vecmath.Tuple3d dimensions)

      Get the corners of a slice in the 3D coordinate space of that slice.

      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+
      originalTLHC - 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 the slice interval
      dimensions - the row and column dimensions and 1 for the third dimension
      Returns:
      an array of four points that are the tlhc,trhc, brhc, blhc of the slice
    • getCornersOfSourceCubeInSourceSpace

      public static javax.vecmath.Point3d[] getCornersOfSourceCubeInSourceSpace(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column, javax.vecmath.Point3d originalTLHC, javax.vecmath.Tuple3d voxelSpacing, double sliceThickness, javax.vecmath.Tuple3d dimensions)

      Get the corners of a volume in the 3D coordinate space of that volume.

      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+
      originalTLHC - 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 the slice interval
      sliceThickness - the slice thickness
      dimensions - the row and column dimensions and number of frames for the third dimension
      Returns:
      an array of eight points that are the tlhcT, trhcT, brhcT, blhcT, tlhcB, trhcB, brhcB, blhcB of the volume
    • getIntersectionOfRectanglesInXYPlane

      public static javax.vecmath.Point3d[] getIntersectionOfRectanglesInXYPlane(javax.vecmath.Point3d[] rect1, javax.vecmath.Point3d[] rect2)
    • getBoundsOfContainedRectangle

      public static Rectangle getBoundsOfContainedRectangle(javax.vecmath.Point3d[] containedRectangle, javax.vecmath.Point3d[] wholeRectangle, Rectangle boundsOfWholeRectangle)
    • transformPointsFromSourceSpaceIntoSpecifiedSpace

      public static javax.vecmath.Point3d[] transformPointsFromSourceSpaceIntoSpecifiedSpace(javax.vecmath.Point3d[] points, javax.vecmath.Point3d tlhc, javax.vecmath.Vector3d row, javax.vecmath.Vector3d column)

      Transform a set of points into the "viewport" defined by an origin and row and column vectors in the same 3D space, by shifting the points to the origin (TLHC) and rotating.

      Parameters:
      points - an array of 3D points to be transformed
      tlhc - the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+
      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+
      Returns:
      a new array of transformed points
    • transformPointFromSourceSpaceIntoSpecifiedSpace

      public static javax.vecmath.Point3d transformPointFromSourceSpaceIntoSpecifiedSpace(javax.vecmath.Point3d point, javax.vecmath.Point3d tlhc, javax.vecmath.Vector3d row, javax.vecmath.Vector3d column)

      Transform a point into the "viewport" defined by an origin and row and column vectors in the same 3D space, by shifting the points to the origin (TLHC) and rotating.

      Parameters:
      point - a 3D point to be transformed
      tlhc - the position of the top left hand corner of the slice as a point (X, Y and Z) LPH+
      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+
      Returns:
      a new, transformed point
    • transformPointFromSourceSpaceIntoLocalizerSpace

      protected javax.vecmath.Point3d transformPointFromSourceSpaceIntoLocalizerSpace(javax.vecmath.Point3d point)

      Transform a point into the "viewport" defined by the localizer that we are an instance of.

      Parameters:
      point - a 3D point to be transformed
      Returns:
      a new, transformed point
    • transformPointInLocalizerPlaneIntoImageSpace

      protected Point2D.Double transformPointInLocalizerPlaneIntoImageSpace(javax.vecmath.Point3d point)

      Project a point in localizer 3D space onto the plane of the localizer by ignoring the Z component, and return the X and Y coordinates as image-TLHC relative column and row offsets.

      Will return sub-pixel values ranging from 0.5 to 0.5 less than the maximum dimensions of the image, which allows points at the very edges of the rendered image to be drawn (e.g. a column of 0.5 will draw at the extreme left and a column of 255.5 will draw at the extreme right of a 256 pixel wide image (whereas 256.0 will not, though 0.0 will).

      Parameters:
      point - the point in 3D localizer space, the Z coordinate of which is ignored
      Returns:
      an array of 2 values in which the column, then the row location on the image is returned
    • drawOutlineOnLocalizer

      protected Vector drawOutlineOnLocalizer(Vector corners)
    • drawOutlineOnLocalizer

      protected Vector drawOutlineOnLocalizer(javax.vecmath.Point3d[] corners)
    • intersectLineBetweenTwoPointsWithPlaneWhereZIsZero

      protected javax.vecmath.Point3d intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(double[] a, double[] b)
    • intersectLineBetweenTwoPointsWithPlaneWhereZIsZero

      protected javax.vecmath.Point3d intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(javax.vecmath.Point3d aP, javax.vecmath.Point3d bP)
    • drawLinesBetweenAnyPointsWhichIntersectPlaneWhereZIsZero

      protected Vector drawLinesBetweenAnyPointsWhichIntersectPlaneWhereZIsZero(javax.vecmath.Point3d[] corners)
    • classifyCornersIntoEdgeCrossingZPlane

      protected static boolean classifyCornersIntoEdgeCrossingZPlane(javax.vecmath.Point3d startCorner, javax.vecmath.Point3d endCorner)
    • getIntersectionsOfCubeWithZPlane

      protected Vector getIntersectionsOfCubeWithZPlane(javax.vecmath.Point3d[] corners)
    • doCommonConstructorStuff

      protected void doCommonConstructorStuff()
    • setLocalizerGeometry

      public void setLocalizerGeometry(javax.vecmath.Vector3d row, javax.vecmath.Vector3d column, javax.vecmath.Point3d tlhc, javax.vecmath.Tuple3d voxelSpacing, javax.vecmath.Tuple3d dimensions)

      Established the geometry of the localizer image to be posted.

      Parameters:
      row - the unit vector (direction cosine) of the row direction in the DICOM coordinate system
      column - the unit vector (direction cosine) of the row direction in the DICOM coordinate system
      tlhc - the position in the DICOM coordinate system of the center of the top left hand corner of the image
      voxelSpacing - the row and column pixel spacing in mm
      dimensions - the number of rows and columns
    • setLocalizerGeometry

      public void setLocalizerGeometry(GeometryOfSlice geometry)

      Established the geometry of the localizer image to be posted.

      Parameters:
      geometry -
    • getOutlineOnLocalizerForThisGeometry

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

      Get the shapes on the localizer of the specified slice.

      Parameters:
      row - the unit vector (direction cosine) of the row direction in the DICOM coordinate system
      column - the unit vector (direction cosine) of the row direction in the DICOM coordinate system
      tlhc - the position in the DICOM coordinate system of the center of the top left hand corner pixel of the slice
      voxelSpacing - the row and column and slice interval in mm
      sliceThickness - the slice thickness in mm
      dimensions - the number of rows and columns and slices
      Returns:
      vector of shapes java.awt.Shape to be drawn in the localizer row and column coordinates
    • getOutlineOnLocalizerForThisGeometry

      public final Vector getOutlineOnLocalizerForThisGeometry(GeometryOfSlice geometry)

      Get the shape on the localizer of a zero-thickness slice specified by the geometry of a 2D rectangle.

      Parameters:
      geometry -
      Returns:
      vector of shapes java.awt.Shape to be drawn in the localizer row and column coordinates
    • getOutlineOnLocalizerForThisVolumeLocalization

      public final Vector getOutlineOnLocalizerForThisVolumeLocalization(SpectroscopyVolumeLocalization spectroscopyVolumeLocalization)

      Get the shape on the localizer of one or more volume localization slabs.

      Parameters:
      spectroscopyVolumeLocalization -
      Returns:
      vector of shapes java.awt.Shape to be drawn in the localizer row and column coordinates