public abstract class LocalizerPoster
extends java.lang.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);
Modifier and Type | Field and Description |
---|---|
protected Vector3d |
localizerColumn |
protected Tuple3d |
localizerDimensions |
protected double[] |
localizerDimensionsArray |
protected Vector3d |
localizerNormal |
protected Vector3d |
localizerRow |
protected Point3d |
localizerTLHC |
protected Tuple3d |
localizerVoxelSpacing |
protected double[] |
localizerVoxelSpacingArray |
protected Matrix3d |
rotateIntoLocalizerSpace |
Modifier and Type | Method and Description |
---|---|
protected static boolean |
classifyCornersIntoEdgeCrossingZPlane(Point3d startCorner,
Point3d endCorner) |
protected void |
doCommonConstructorStuff() |
protected java.util.Vector |
drawLinesBetweenAnyPointsWhichIntersectPlaneWhereZIsZero(Point3d[] corners) |
protected java.util.Vector |
drawOutlineOnLocalizer(Point3d[] corners) |
protected java.util.Vector |
drawOutlineOnLocalizer(java.util.Vector corners) |
static java.awt.Rectangle |
getBoundsOfContainedRectangle(Point3d[] containedRectangle,
Point3d[] wholeRectangle,
java.awt.Rectangle boundsOfWholeRectangle) |
static Point3d[] |
getCornersOfSourceCubeInSourceSpace(Vector3d row,
Vector3d column,
Point3d originalTLHC,
Tuple3d voxelSpacing,
double sliceThickness,
Tuple3d dimensions)
Get the corners of a volume in the 3D coordinate space of that volume.
|
static Point3d[] |
getCornersOfSourceRectangleInSourceSpace(GeometryOfSlice g)
Get the corners of a slice in the 3D coordinate space of that slice.
|
static Point3d[] |
getCornersOfSourceRectangleInSourceSpace(Vector3d row,
Vector3d column,
Point3d originalTLHC,
Tuple3d voxelSpacing,
Tuple3d dimensions)
Get the corners of a slice in the 3D coordinate space of that slice.
|
static Point3d[] |
getIntersectionOfRectanglesInXYPlane(Point3d[] rect1,
Point3d[] rect2) |
protected java.util.Vector |
getIntersectionsOfCubeWithZPlane(Point3d[] corners) |
java.util.Vector |
getOutlineOnLocalizerForThisGeometry(GeometryOfSlice geometry)
Get the shape on the localizer of a zero-thickness slice specified by the geometry of a 2D rectangle.
|
abstract java.util.Vector |
getOutlineOnLocalizerForThisGeometry(Vector3d row,
Vector3d column,
Point3d tlhc,
Tuple3d voxelSpacing,
double sliceThickness,
Tuple3d dimensions)
Get the shapes on the localizer of the specified slice.
|
java.util.Vector |
getOutlineOnLocalizerForThisVolumeLocalization(SpectroscopyVolumeLocalization spectroscopyVolumeLocalization)
Get the shape on the localizer of one or more volume localization slabs.
|
protected Point3d |
intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(double[] a,
double[] b) |
protected Point3d |
intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(Point3d aP,
Point3d bP) |
void |
setLocalizerGeometry(GeometryOfSlice geometry)
Established the geometry of the localizer image to be posted.
|
void |
setLocalizerGeometry(Vector3d row,
Vector3d column,
Point3d tlhc,
Tuple3d voxelSpacing,
Tuple3d dimensions)
Established the geometry of the localizer image to be posted.
|
protected Point3d |
transformPointFromSourceSpaceIntoLocalizerSpace(Point3d point)
Transform a point into the "viewport" defined by the localizer that we are an instance of.
|
static Point3d |
transformPointFromSourceSpaceIntoSpecifiedSpace(Point3d point,
Point3d tlhc,
Vector3d row,
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.
|
protected java.awt.geom.Point2D.Double |
transformPointInLocalizerPlaneIntoImageSpace(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.
|
static Point3d[] |
transformPointsFromSourceSpaceIntoSpecifiedSpace(Point3d[] points,
Point3d tlhc,
Vector3d row,
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.
|
static void |
validateDirectionCosines(Vector3d row,
Vector3d column)
Check that the row and column vectors are unit vectors and are orthogonal.
|
static void |
validateDirectionCosines(Vector3d row,
Vector3d column,
Vector3d normal)
Check that the row and column and slice direction vectors are unit vectors and are orthogonal.
|
protected Vector3d localizerRow
protected Vector3d localizerColumn
protected Vector3d localizerNormal
protected Point3d localizerTLHC
protected Tuple3d localizerVoxelSpacing
protected double[] localizerVoxelSpacingArray
protected Tuple3d localizerDimensions
protected double[] localizerDimensionsArray
protected Matrix3d rotateIntoLocalizerSpace
public static void validateDirectionCosines(Vector3d row, Vector3d column) throws java.lang.IllegalArgumentException
Check that the row and column vectors are unit vectors and are orthogonal.
row
- the row direction cosinescolumn
- the column direction cosinesjava.lang.IllegalArgumentException
- thrown if notpublic static void validateDirectionCosines(Vector3d row, Vector3d column, Vector3d normal) throws java.lang.IllegalArgumentException
Check that the row and column and slice direction vectors are unit vectors and are orthogonal.
row
- the row direction cosinescolumn
- the column direction cosinesnormal
- the normal to the row and column plane (the slice direction)java.lang.IllegalArgumentException
- thrown if notpublic static Point3d[] getCornersOfSourceRectangleInSourceSpace(GeometryOfSlice g)
Get the corners of a slice in the 3D coordinate space of that slice.
g
- the geometry of a slicepublic static Point3d[] getCornersOfSourceRectangleInSourceSpace(Vector3d row, Vector3d column, Point3d originalTLHC, Tuple3d voxelSpacing, Tuple3d dimensions)
Get the corners of a slice in the 3D coordinate space of that slice.
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 intervaldimensions
- the row and column dimensions and 1 for the third dimensionpublic static Point3d[] getCornersOfSourceCubeInSourceSpace(Vector3d row, Vector3d column, Point3d originalTLHC, Tuple3d voxelSpacing, double sliceThickness, Tuple3d dimensions)
Get the corners of a volume in the 3D coordinate space of that volume.
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 intervalsliceThickness
- the slice thicknessdimensions
- the row and column dimensions and number of frames for the third dimensionpublic static Point3d[] getIntersectionOfRectanglesInXYPlane(Point3d[] rect1, Point3d[] rect2)
public static java.awt.Rectangle getBoundsOfContainedRectangle(Point3d[] containedRectangle, Point3d[] wholeRectangle, java.awt.Rectangle boundsOfWholeRectangle)
public static Point3d[] transformPointsFromSourceSpaceIntoSpecifiedSpace(Point3d[] points, Point3d tlhc, Vector3d row, 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.
points
- an array of 3D points to be transformedtlhc
- 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+public static Point3d transformPointFromSourceSpaceIntoSpecifiedSpace(Point3d point, Point3d tlhc, Vector3d row, 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.
point
- a 3D point to be transformedtlhc
- 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+protected Point3d transformPointFromSourceSpaceIntoLocalizerSpace(Point3d point)
Transform a point into the "viewport" defined by the localizer that we are an instance of.
point
- a 3D point to be transformedprotected java.awt.geom.Point2D.Double transformPointInLocalizerPlaneIntoImageSpace(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).
point
- the point in 3D localizer space, the Z coordinate of which is ignoredprotected java.util.Vector drawOutlineOnLocalizer(java.util.Vector corners)
protected java.util.Vector drawOutlineOnLocalizer(Point3d[] corners)
protected Point3d intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(double[] a, double[] b)
protected Point3d intersectLineBetweenTwoPointsWithPlaneWhereZIsZero(Point3d aP, Point3d bP)
protected java.util.Vector drawLinesBetweenAnyPointsWhichIntersectPlaneWhereZIsZero(Point3d[] corners)
protected static boolean classifyCornersIntoEdgeCrossingZPlane(Point3d startCorner, Point3d endCorner)
protected java.util.Vector getIntersectionsOfCubeWithZPlane(Point3d[] corners)
protected void doCommonConstructorStuff()
public void setLocalizerGeometry(Vector3d row, Vector3d column, Point3d tlhc, Tuple3d voxelSpacing, Tuple3d dimensions)
Established the geometry of the localizer image to be posted.
row
- the unit vector (direction cosine) of the row direction in the DICOM coordinate systemcolumn
- the unit vector (direction cosine) of the row direction in the DICOM coordinate systemtlhc
- the position in the DICOM coordinate system of the center of the top left hand corner of the imagevoxelSpacing
- the row and column pixel spacing in mmdimensions
- the number of rows and columnspublic void setLocalizerGeometry(GeometryOfSlice geometry)
Established the geometry of the localizer image to be posted.
geometry
- public abstract java.util.Vector getOutlineOnLocalizerForThisGeometry(Vector3d row, Vector3d column, Point3d tlhc, Tuple3d voxelSpacing, double sliceThickness, Tuple3d dimensions)
Get the shapes on the localizer of the specified slice.
row
- the unit vector (direction cosine) of the row direction in the DICOM coordinate systemcolumn
- the unit vector (direction cosine) of the row direction in the DICOM coordinate systemtlhc
- the position in the DICOM coordinate system of the center of the top left hand corner pixel of the slicevoxelSpacing
- the row and column and slice interval in mmsliceThickness
- the slice thickness in mmdimensions
- the number of rows and columns and slicesjava.awt.Shape
to be drawn in the localizer row and column coordinatespublic final java.util.Vector getOutlineOnLocalizerForThisGeometry(GeometryOfSlice geometry)
Get the shape on the localizer of a zero-thickness slice specified by the geometry of a 2D rectangle.
geometry
- java.awt.Shape
to be drawn in the localizer row and column coordinatespublic final java.util.Vector getOutlineOnLocalizerForThisVolumeLocalization(SpectroscopyVolumeLocalization spectroscopyVolumeLocalization)
Get the shape on the localizer of one or more volume localization slabs.
spectroscopyVolumeLocalization
- java.awt.Shape
to be drawn in the localizer row and column coordinates