Class VoxelsUntyped

Object
VoxelsUntyped

public class VoxelsUntyped extends Object
Stores memory buffers representing image voxels, without explicit typing of buffers.

This is a convenience class to avoid using a templated parameter in Voxels.

It stores the voxels in a weakly-typed manner, and gives convenience methods to convert to the desired type.

An IncorrectVoxelTypeException is thrown when incorrect assumptions are made about the type.

Author:
Owen Feehan
  • Constructor Details

    • VoxelsUntyped

      public VoxelsUntyped(Voxels<?> voxels)
      Creates to wrap a Voxels of unspecified type.
      Parameters:
      voxels - the voxels to wrap, whose memory is reused without duplication.
  • Method Details

    • any

      public Voxels<?> any()
      Exposes without any specific buffer type.
      Returns:
      the current object, without typing on the buffer.
    • checkIdenticalDataType

      public Voxels<?> checkIdenticalDataType(VoxelDataType match)
      Do the voxels have a data-type that is equal to match?
      Parameters:
      match - the data-type the voxel must equal.
      Returns:
      true iff the voxel data-type is equal.
    • asByte

      public Voxels<UnsignedByteBuffer> asByte()
      Casts to use a UnsignedByteBuffer if the voxels contain this data-type, otherwise throws a IncorrectVoxelTypeException.
      Returns:
      the cast voxels.
    • asShort

      public Voxels<UnsignedShortBuffer> asShort()
      Casts to use a UnsignedShortBuffer if the voxels contain this data-type, otherwise throws a IncorrectVoxelTypeException.
      Returns:
      the cast voxels.
    • asInt

      public Voxels<UnsignedIntBuffer> asInt()
      Casts to use a UnsignedIntBuffer if the voxels contain this data-type, otherwise throws a IncorrectVoxelTypeException.
      Returns:
      the cast voxels.
    • asFloat

      public Voxels<FloatBuffer> asFloat()
      Casts to use a FloatBuffer if the voxels contain this data-type, otherwise throws a IncorrectVoxelTypeException.
      Returns:
      the cast voxels.
    • getVoxelDataType

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

      public void copyVoxelsTo(BoundingBox boxSource, VoxelsUntyped destination, BoundingBox boxDestination)
      Copies the voxels into a destination, but only those voxels inside a bounding-box.
      Parameters:
      boxSource - the bounding-box relative to the source voxels (the current voxels - from where we copy from).
      destination - the voxels we copy into.
      boxDestination - the bounding-box relative to the destination voxels.
    • copyVoxelsTo

      public void copyVoxelsTo(ObjectMask objectSource, VoxelsUntyped destination, BoundingBox boxDestination)
      Copies the voxels into a destination, but only those voxels inside an ObjectMask.
      Parameters:
      objectSource - the object-mask relative to the source voxels, from where we copy from.
      destination - the voxels we copy into.
      boxDestination - the bounding-box relative to the destination voxels.
    • subtractFromMaxValue

      public void subtractFromMaxValue()
      Subtracts all voxel-values from the maximum value associated with the data-type.

      i.e. each voxel value v is updated to become maxDataTypeValue - v

    • replaceSlice

      public void replaceSlice(int sliceIndexToUpdate, VoxelsUntyped sourceVoxels, int sliceIndexSource, boolean duplicate)
      Copies one particular z-slice of voxels from a source into the current voxels.

      The existing z-slice is replaced.

      Parameters:
      sliceIndexToUpdate - slice-index to update in the current voxels.
      sourceVoxels - voxels to copy a particular z-slice from.
      sliceIndexSource - the z-slice in sourceVoxels to copy from.
      duplicate - if true, the source slice is duplicated before being assigned. Otherwise it is reused.
    • slice

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

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

      public VoxelsArithmetic arithmetic()
      Interface that allows manipulation of voxel intensities via arithmetic operations.
      Returns:
      the interface.
    • assignValue

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

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