Class Voxels<T>

Object
Voxels<T>
Type Parameters:
T - buffer-type
Direct Known Subclasses:
VoxelsFloat, VoxelsUnsignedByte, VoxelsUnsignedInt, VoxelsUnsignedShort

public abstract class Voxels<T> extends Object
A box (3-dimensions) with voxel-data.

This class is almost immutable, with the exception of the buffers containing intensity values which can be modified.

All operations that can modify the state (i.e. mutable operations) are provided via the assignValue(int) or arithmetic() or replaceSlice(int, org.anchoranalysis.image.voxel.buffer.VoxelBuffer<T>) or slice(int) or sliceBuffer(int) methods. Other operations are all immutable.

See VoxelsUntyped for a similar class that exposes the voxel-data type as a run-time accessible field.

Author:
Owen Feehan
  • Field Details

    • MAX_IN_TO_STRING

      public static final Extent MAX_IN_TO_STRING
      The maximum number of rows/columns/slices to show in toString().
  • Constructor Details

    • Voxels

      public Voxels(SliceBufferIndex<T> slices, VoxelsFactoryTypeBound<T> factory, VoxelsArithmetic arithmetic)
      Creates a new Voxels instance.
      Parameters:
      slices - An index mapping slice of voxels (in the z dimension) to a particular buffer with the corresponding voxel intensities.
      factory - A factory for creating voxels with a particular buffer-type.
      arithmetic - Interface that allows manipulation of voxel intensities via arithmetic operations.
  • Method Details

    • extract

      public abstract VoxelsExtracter<T> extract()
      Interface that allows read/copy/duplication operations to be performed regarding the voxels intensities.
      Returns:
      the interface.
    • assignValue

      public abstract VoxelsAssigner assignValue(int valueToAssign)
      Interface that allows assignment of a particular value to all or subsets of the voxels.
      Parameters:
      valueToAssign - the value to assign.
      Returns:
      the interface.
    • dataType

      public VoxelDataType dataType()
      The underlying data-type of the voxels, represented by a VoxelDataType instance.
      Returns:
      an instance of VoxelDataType.
    • slice

      public VoxelBuffer<T> slice(int z)
      A VoxelBuffer corresponding to a particular z-slice.
      Parameters:
      z - the index (beginning at 0) of the respective z-slice.
      Returns:
      the corresponding buffer for z.
    • sliceBuffer

      public T sliceBuffer(int z)
      A buffer corresponding to a particular z-slice.

      This buffer is either a NIO class or another class that wraps the underlying array storing voxel intensities.

      Parameters:
      z - the index (beginning at 0) of the respective z-slice.
      Returns:
      the corresponding buffer for z.
    • extent

      public Extent extent()
      The size of the voxels across three dimensions.
      Returns:
      the size.
    • duplicate

      public Voxels<T> duplicate()
      A deep-copy.
      Returns:
      newly created deep-copy.
    • equalsDeep

      public boolean equalsDeep(Voxels<?> other)
      Are the voxels identical to another voxels (deep equals)?
      Parameters:
      other - the other voxels to compare with.
      Returns:
      true if the size, data-type and each voxel-value of both are identical.
    • replaceSlice

      public void replaceSlice(int sliceIndexToUpdate, VoxelBuffer<T> bufferToAssign)
      Assigns a new buffer for a particular slice.

      This is a mutable operation.

      Parameters:
      sliceIndexToUpdate - slice-index to update.
      bufferToAssign - buffer to assign.
    • toString

      public String toString()
      Print a description and the the first MAX_IN_TO_STRING (if they exist) rows and columns as values.
      Overrides:
      toString in class Object
    • slices

      public SliceBufferIndex<T> slices()
      An index mapping slice of voxels (in the z dimension) to a particular buffer with the corresponding voxel intensities.
    • factory

      public VoxelsFactoryTypeBound<T> factory()
      A factory for creating voxels with a particular buffer-type.
    • arithmetic

      public VoxelsArithmetic arithmetic()
      Interface that allows manipulation of voxel intensities via arithmetic operations.