Class Dimensions
Object
Dimensions
The size of an image (in voxels), together with the image resolution.
The image resolution is the physical size of each voxel, if known.
This class is immutable.
-
Constructor Summary
ConstructorsConstructorDescriptionDimensions
(int x, int y, int z) Construct with an explicit extent and no resolution.Dimensions
(Extent extent) Construct with an explicit extent and no resolution.Dimensions
(Extent extent, Optional<Resolution> resolution) Creates a newDimensions
instance.Dimensions
(ReadableTuple3i extent) Construct with an explicit extent and no resolution. -
Method Summary
Modifier and TypeMethodDescriptionint
areaXY()
Size in X multiplied by size in Y.long
Calculates the volume of theExtent
when considered as a box.boolean
contains
(BoundingBox box) Isbox
entirely contained within the extent?boolean
Is a point of typePoint3d
contained within the extent?boolean
Is a point of typeReadableTuple3i
contained within theExtent
?duplicateChangeExtent
(Extent extentToAssign) Deep-copies the current object, but assigns a differentExtent
.duplicateChangeResolution
(Optional<Resolution> resolutionToAssign) Deep-copies the current object, but assigns a differentResolution
.duplicateChangeZ
(int z) Deep-copies the current object, but assigns a different size for the Z-dimension.boolean
boolean
equals
(Dimensions other, boolean compareResolution) Checks equality between this object and anotherDimensions
, but possibly skipping a comparison of image-resolution in the check.extent()
The width and height and depth of the image.int
hashCode()
int
offset
(int x, int y) Calculates a XY-offset of a point in a buffer whose dimensions are this extent.final int
Calculates a XYZ-offset of a point in a buffer whose dimensions are this extent.final int
offsetSlice
(Point3i point) Calculates a XY-offset of a point in a buffer whose dimensions are this extent.resizeXY
(int x, int y) Resizes the dimensions to have new sizes in the X and Y dimension.Resolution of voxels to physical measurements.scaleXYBy
(ScaleFactor scaleFactor) Scales the X- and Y- dimensions by a scaling-factor.toString()
Converts voxel-scaled measurements to/from physical units.int
x()
The size in the X dimension.int
y()
The size in the Y dimension.int
z()
The size in the Z dimension.
-
Constructor Details
-
Dimensions
public Dimensions(int x, int y, int z) Construct with an explicit extent and no resolution.- Parameters:
x
- the size of the X-dimension in voxels.y
- the size of the Y-dimension in voxels.z
- the size of the Z-dimension in voxels.
-
Dimensions
Construct with an explicit extent and no resolution.- Parameters:
extent
- the size of the image in voxels, for respectively the X, Y and Z dimensions.
-
Dimensions
Construct with an explicit extent and no resolution.- Parameters:
extent
- the size of the image in voxels.
-
Dimensions
Creates a newDimensions
instance.- Parameters:
extent
- The width and height and depth of the image.i.e. the size of each of the three possible dimensions.
resolution
- Resolution of voxels to physical measurements.e.g. physical size of each voxel in a particular dimension.
-
-
Method Details
-
resizeXY
Resizes the dimensions to have new sizes in the X and Y dimension.The z-dimension remains unchanged.
The resolution is also scaled accordingly, so the image refers to the same physical size, before and after scaling..
- Parameters:
x
- the new size to assign in the X-dimension.y
- the new size to assign in the Y-dimension.- Returns:
- a newly created
Channel
containing a resized version of the current.
-
scaleXYBy
Scales the X- and Y- dimensions by a scaling-factor.The resolution is also scaled, so the image refers to the same physical size, before and after scaling..
- Parameters:
scaleFactor
- the scaling-factor to multiply the respective X and Y dimension values by.- Returns:
- a new
Extent
whose X and Y values are scaled versions of the current values, and Z value is unchanged.
-
duplicateChangeExtent
Deep-copies the current object, but assigns a differentExtent
.- Parameters:
extentToAssign
- the extent to assign.- Returns:
- a copy, but with the assigned extent.
-
duplicateChangeZ
Deep-copies the current object, but assigns a different size for the Z-dimension.- Parameters:
z
- the size in the Z-dimension.- Returns:
- a copy, but with the assigned extent.
-
duplicateChangeResolution
Deep-copies the current object, but assigns a differentResolution
.- Parameters:
resolutionToAssign
- the resolution to assign.- Returns:
- a copy, but with the assigned resolution.
-
calculateVolume
public long calculateVolume()Calculates the volume of theExtent
when considered as a box.This is is the size in the X, Y and Z dimensions multiplied together.
- Returns:
- the volume in voxels.
-
areaXY
public int areaXY()Size in X multiplied by size in Y.This may be convenient for calculating offsets and for iterations.
- Returns:
- the area (in square voxels).
-
x
public int x()The size in the X dimension.- Returns:
- the size.
-
y
public int y()The size in the Y dimension.- Returns:
- the size.
-
z
public int z()The size in the Z dimension.- Returns:
- the size.
-
offset
public int offset(int x, int y) Calculates a XY-offset of a point in a buffer whose dimensions are this extent.- Parameters:
x
- the value in the X-dimension for the point.y
- the value in the Y-dimension for the point.- Returns:
- the offset, pertaining only to all dimensions.
-
contains
Is a point of typePoint3d
contained within the extent?- Parameters:
point
- the point to check.- Returns:
- true iff the point exists within the extent, considering all axes.
-
contains
Is a point of typeReadableTuple3i
contained within theExtent
?- Parameters:
point
- the point to check.- Returns:
- true iff the point exists within the
Extent
, considering all axes.
-
offset
Calculates a XYZ-offset of a point in a buffer whose dimensions are this extent.- Parameters:
point
- the point to calculate an offset for.- Returns:
- the offset, pertaining only to all dimensions.
-
offsetSlice
Calculates a XY-offset of a point in a buffer whose dimensions are this extent.- Parameters:
point
- the point to calculate an offset for.- Returns:
- the offset, pertaining only to the X and Y dimensions.
-
contains
Isbox
entirely contained within the extent?- Parameters:
box
- the bounding-box to check.- Returns:
- true iff only describes space contained in the current extent.
-
unitConvert
Converts voxel-scaled measurements to/from physical units.- Returns:
- a converter that will perform conversions using current resolution.
-
equals
Checks equality between this object and anotherDimensions
, but possibly skipping a comparison of image-resolution in the check.- Parameters:
other
- the object to compare with.compareResolution
- if true image resolution is compared, otherwise it is not considered.- Returns:
- true iff the two objects are equal by the above criteria.
-
equals
-
hashCode
public int hashCode() -
toString
-
extent
The width and height and depth of the image.i.e. the size of each of the three possible dimensions.
-
resolution
Resolution of voxels to physical measurements.e.g. physical size of each voxel in a particular dimension.
-