Class Resolution
Object
Resolution
- All Implemented Interfaces:
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
ConstructorsConstructorDescriptionCreates 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.Resolution
(Tuple3d tuple) Constructs a resolution from a tuple. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
hashCode()
scaleXY
(ScaleFactor scaleFactor) Multiplies the X and Y components of the resolution by a factor.toString()
double
unitArea()
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
valueByDimension
(Axis axis) 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 likez()
if the z-resolution is notDouble.NaN
.double
Gives the relative resolution of the z-component to the x-component.
-
Constructor Details
-
Resolution
public Resolution()Creates with a default resolution with value 1.0 in each dimension. -
Resolution
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 aDouble.NaN
for the X or Y components.
-
Resolution
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 aDouble.NaN
for the X or Y components.
-
-
Method Details
-
createWithXY
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
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 likez()
if the z-resolution is notDouble.NaN
.Otherwise returns
fallback
.- Parameters:
fallback
- the value to return if the z-resolution isDouble.NaN
.- Returns:
- either the z-resolution (if not
Double.NaN
) orfallback
.
-
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
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
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
-
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 perAxisConverter
.- Returns:
- the component of the tuple corresponding to that axis.
-
valueByDimension
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
-
hashCode
public int hashCode()
-