Class Dimensions

Object
Dimensions

public final class Dimensions extends Object
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 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

      public Dimensions(ReadableTuple3i extent)
      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

      public Dimensions(Extent extent)
      Construct with an explicit extent and no resolution.
      Parameters:
      extent - the size of the image in voxels.
    • Dimensions

      public Dimensions(Extent extent, Optional<Resolution> resolution)
      Creates a new Dimensions 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

      public Dimensions resizeXY(int x, int y)
      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

      public Dimensions scaleXYBy(ScaleFactor scaleFactor)
      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

      public Dimensions duplicateChangeExtent(Extent extentToAssign)
      Deep-copies the current object, but assigns a different Extent.
      Parameters:
      extentToAssign - the extent to assign.
      Returns:
      a copy, but with the assigned extent.
    • duplicateChangeZ

      public Dimensions duplicateChangeZ(int z)
      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

      public Dimensions duplicateChangeResolution(Optional<Resolution> resolutionToAssign)
      Deep-copies the current object, but assigns a different Resolution.
      Parameters:
      resolutionToAssign - the resolution to assign.
      Returns:
      a copy, but with the assigned resolution.
    • calculateVolume

      public long calculateVolume()
      Calculates the volume of the Extent 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

      public boolean contains(Point3d point)
      Is a point of type Point3d contained within the extent?
      Parameters:
      point - the point to check.
      Returns:
      true iff the point exists within the extent, considering all axes.
    • contains

      public boolean contains(Point3i point)
      Is a point of type ReadableTuple3i contained within the Extent?
      Parameters:
      point - the point to check.
      Returns:
      true iff the point exists within the Extent, considering all axes.
    • offset

      public final int offset(Point3i point)
      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

      public final int offsetSlice(Point3i point)
      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

      public boolean contains(BoundingBox box)
      Is box entirely contained within the extent?
      Parameters:
      box - the bounding-box to check.
      Returns:
      true iff only describes space contained in the current extent.
    • unitConvert

      public Optional<UnitConverter> unitConvert()
      Converts voxel-scaled measurements to/from physical units.
      Returns:
      a converter that will perform conversions using current resolution.
    • equals

      public 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.
      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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • extent

      public Extent extent()
      The width and height and depth of the image.

      i.e. the size of each of the three possible dimensions.

    • resolution

      public Optional<Resolution> resolution()
      Resolution of voxels to physical measurements.

      e.g. physical size of each voxel in a particular dimension.