Class Resolution

Object
Resolution
All Implemented Interfaces:
Serializable

public final class Resolution extends Object implements Serializable
The resolution of an image.

i.e. what a single voxel represents in physical units (meters) in x, y, z dimensions.

This class is immutable.

Author:
Owen Feehan
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates with a default resolution with value 1.0 in each dimension.
    Resolution(double x, double y, double z)
    Creates with a resolution from three double values for each dimension.
    Constructs a resolution from a tuple.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Resolution
    createWithXY(double xy)
    Creates with only XY resolution, identical in both dimensions.
    static Resolution
    createWithXYAndZ(double xy, double z)
    Creates with XY resolution and Z resolution.
    boolean
     
    int
     
    scaleXY(ScaleFactor scaleFactor)
    Multiplies the X and Y components of the resolution by a factor.
     
    double
    Multiplying the X- and Y- resolution values together.
    Converts voxelized measurements to/from physical units.
    double
    Multiplying the X- and Y- and Z- resolution values together.
    final double
    valueByDimension(int dimensionIndex)
    A component of a resolution corresponding to a particular dimension by index.
    final double
    A component of the tuple corresponding to a particular axis.
    double
    x()
    The resolution in the X-dimension in meters.
    double
    y()
    The resolution in the Y-dimension in meters.
    double
    z()
    The resolution in the Z-dimension in meters.
    double
    zIfDefined(double fallback)
    Returns the z-resolution like z() if the z-resolution is not Double.NaN.
    double
    Gives the relative resolution of the z-component to the x-component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Resolution

      public Resolution()
      Creates with a default resolution with value 1.0 in each dimension.
    • Resolution

      public Resolution(double x, double y, double z) throws CreateException
      Creates with a resolution from three double values for each dimension.

      Note all dimensions must have positive (i.e. non-zero) resolution.

      X and Y are not allowed have NaN but this is acceptable for the Z-value.

      Parameters:
      x - the resolution for the X-dimension.
      y - the resolution for the Y-dimension.
      z - the resolution for the Z-dimension.
      Throws:
      CreateException - if a non-positive value is passed, or a Double.NaN for the X or Y components.
    • Resolution

      public Resolution(Tuple3d tuple) throws CreateException
      Constructs a resolution from a tuple.

      Note all dimensions must have positive (i.e. non-zero) resolution.

      X and Y are not allowed have NaN but this is acceptable for the Z-value.

      Parameters:
      tuple - the resolution for X, Y and Z.
      Throws:
      CreateException - if a non-positive value is passed, or a Double.NaN for the X or Y components.
  • Method Details

    • createWithXY

      public static Resolution createWithXY(double xy)
      Creates with only XY resolution, identical in both dimensions.

      Z-resolution is considered unknown.

      Parameters:
      xy - the resolution in meters for both x and y dimension.
      Returns:
      the resolution.
    • createWithXYAndZ

      public static Resolution createWithXYAndZ(double xy, double z)
      Creates with XY resolution and Z resolution.

      The X and Y resolution is considered identical in both dimensions.

      Parameters:
      xy - the resolution in meters for both x and y dimension.
      z - the resolution in meters for the z dimension.
      Returns:
      the resolution.
    • x

      public double x()
      The resolution in the X-dimension in meters.
      Returns:
      the resolution in meters.
    • y

      public double y()
      The resolution in the Y-dimension in meters.
      Returns:
      the resolution in meters.
    • z

      public double z()
      The resolution in the Z-dimension in meters.
      Returns:
      the resolution in meters, or Double.NaN if it is not defined.
    • zIfDefined

      public double zIfDefined(double fallback)
      Returns the z-resolution like z() if the z-resolution is not Double.NaN.

      Otherwise returns fallback.

      Parameters:
      fallback - the value to return if the z-resolution is Double.NaN.
      Returns:
      either the z-resolution (if not Double.NaN) or fallback.
    • unitVolume

      public double unitVolume()
      Multiplying the X- and Y- and Z- resolution values together.
      Returns:
      the volume in cubic meters, or Double.NaN if the Z-resolution is undefined.
    • unitArea

      public double unitArea()
      Multiplying the X- and Y- resolution values together.
      Returns:
      the area in square meters.
    • scaleXY

      public Resolution scaleXY(ScaleFactor scaleFactor)
      Multiplies the X and Y components of the resolution by a factor.

      This is an immutable operation.

      Parameters:
      scaleFactor - the factor to multiply each dimension by.
      Returns:
      a newly created Resolution that is the result of the scaling.
    • unitConvert

      public UnitConverter unitConvert()
      Converts voxelized measurements to/from physical units.
      Returns:
      a converter that will perform conversions using current resolution.
    • zRelative

      public double zRelative()
      Gives the relative resolution of the z-component to the x-component.
      Returns:
      the z-component divided by the x-component.
    • toString

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

      public final double valueByDimension(int dimensionIndex)
      A component of a resolution corresponding to a particular dimension by index.
      Parameters:
      dimensionIndex - the index corresponding to an axis, as per AxisConverter.
      Returns:
      the component of the tuple corresponding to that axis.
    • valueByDimension

      public final double valueByDimension(Axis axis)
      A component of the tuple corresponding to a particular axis.
      Parameters:
      axis - the axis.
      Returns:
      the component of the tuple corresponding to that axis.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object