public final class Dimensions extends Object
The image resolution is the physical size of each voxel, if known.
This class is immutable.
Constructor and Description |
---|
Dimensions(Extent extent)
Construct with an explicit extent and no resolution.
|
Dimensions(Extent extent,
Optional<Resolution> resolution) |
Dimensions(int x,
int y,
int z)
Construct with an explicit extent and no resolution.
|
Dimensions(ReadableTuple3i extent)
Construct with an explicit extent and no resolution.
|
Modifier and Type | Method and Description |
---|---|
int |
areaXY()
Size in X multiplied by size in Y.
|
long |
calculateVolume()
Calculates the volume of the
Extent when considered as a box. |
boolean |
contains(BoundingBox box)
Is
box entirely contained within the extent? |
boolean |
contains(Point3d point)
Is a point of type
Point3d contained within the extent? |
boolean |
contains(Point3i point)
Is a point of type
ReadableTuple3i contained within the Extent ? |
Dimensions |
duplicateChangeExtent(Extent extentToAssign)
Deep-copies the current object, but assigns a different
Extent . |
Dimensions |
duplicateChangeResolution(Optional<Resolution> resolutionToAssign)
Deep-copies the current object, but assigns a different
Resolution . |
Dimensions |
duplicateChangeZ(int z)
Deep-copies the current object, but assigns a different size for the Z-dimension.
|
boolean |
equals(Dimensions other,
boolean compareResolution)
Checks equality between this object and another
Dimensions , but possibly skipping a
comparison of image-resolution in the check. |
boolean |
equals(Object o) |
Extent |
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.
|
int |
offset(Point3i point)
Calculates a XYZ-offset of a point in a buffer whose dimensions are this extent.
|
int |
offsetSlice(Point3i point)
Calculates a XY-offset of a point in a buffer whose dimensions are this extent.
|
Dimensions |
resizeXY(int x,
int y)
Resizes the dimensions to have new sizes in the X and Y dimension.
|
Optional<Resolution> |
resolution()
Resolution of voxels to physical measurements.
|
Dimensions |
scaleXYBy(ScaleFactor scaleFactor)
Scales the X- and Y- dimensions by a scaling-factor.
|
String |
toString() |
Optional<UnitConverter> |
unitConvert()
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.
|
public Dimensions(int x, int y, int z)
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.public Dimensions(ReadableTuple3i extent)
extent
- the size of the image in voxels, for respectively the X, Y and
Z dimensions.public Dimensions(Extent extent)
extent
- the size of the image in voxels.public Dimensions(Extent extent, Optional<Resolution> resolution)
public Dimensions resizeXY(int x, int y)
The z-dimension remains unchanged.
The resolution is also scaled accordingly, so the image refers to the same physical size, before and after scaling..
x
- the new size to assign in the X-dimension.y
- the new size to assign in the Y-dimension.Channel
containing a resized version of the current.public Dimensions scaleXYBy(ScaleFactor scaleFactor)
The resolution is also scaled, so the image refers to the same physical size, before and after scaling..
scaleFactor
- the scaling-factor to multiply the respective X and Y dimension values by.Extent
whose X and Y values are scaled versions of the current values,
and Z value is unchanged.public Dimensions duplicateChangeExtent(Extent extentToAssign)
Extent
.extentToAssign
- the extent to assign.public Dimensions duplicateChangeZ(int z)
z
- the size in the Z-dimension.public Dimensions duplicateChangeResolution(Optional<Resolution> resolutionToAssign)
Resolution
.resolutionToAssign
- the resolution to assign.public long calculateVolume()
Extent
when considered as a box.
This is is the size in the X, Y and Z dimensions multiplied together.
public int areaXY()
This may be convenient for calculating offsets and for iterations.
public int x()
public int y()
public int z()
public int offset(int x, int y)
x
- the value in the X-dimension for the point.y
- the value in the Y-dimension for the point.public boolean contains(Point3d point)
Point3d
contained within the extent?point
- the point to check.public boolean contains(Point3i point)
ReadableTuple3i
contained within the Extent
?point
- the point to check.Extent
, considering all axes.public final int offset(Point3i point)
point
- the point to calculate an offset for.public final int offsetSlice(Point3i point)
point
- the point to calculate an offset for.public boolean contains(BoundingBox box)
box
entirely contained within the extent?box
- the bounding-box to check.public Optional<UnitConverter> unitConvert()
public boolean equals(Dimensions other, boolean compareResolution)
Dimensions
, but possibly skipping a
comparison of image-resolution in the check.other
- the object to compare with.compareResolution
- if true image resolution is compared, otherwise it is not
considered.public Extent extent()
i.e. the size of each of the three possible dimensions.
public Optional<Resolution> resolution()
e.g. physical size of each voxel in a particular dimension.
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.