Package org.anchoranalysis.image.voxel
Class VoxelsUntyped
Object
VoxelsUntyped
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 Summary
ConstructorsConstructorDescriptionVoxelsUntyped(Voxels<?> voxels) Creates to wrap aVoxelsof unspecified type. -
Method Summary
Modifier and TypeMethodDescriptionVoxels<?> any()Exposes without any specific buffer type.Interface that allows manipulation of voxel intensities via arithmetic operations.asByte()Casts to use aUnsignedByteBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.asFloat()Casts to use aFloatBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.asInt()Casts to use aUnsignedIntBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.asShort()Casts to use aUnsignedShortBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.assignValue(int valueToAssign) Interface that allows assignment of a particular value to all or subsets of the voxels.Voxels<?> Do the voxels have a data-type that is equal tomatch?voidcopyVoxelsTo(ObjectMask objectSource, VoxelsUntyped destination, BoundingBox boxDestination) Copies the voxels into adestination, but only those voxels inside anObjectMask.voidcopyVoxelsTo(BoundingBox boxSource, VoxelsUntyped destination, BoundingBox boxDestination) Copies the voxels into adestination, but only those voxels inside a bounding-box.extent()The size of the voxels across three dimensions.extract()Interface that allows read/copy/duplication operations to be performed regarding the voxels intensities.The underlying data-type of the voxels, represented by aVoxelDataTypeinstance.voidreplaceSlice(int sliceIndexToUpdate, VoxelsUntyped sourceVoxels, int sliceIndexSource, boolean duplicate) Copies one particular z-slice of voxels from a source into the current voxels.<T> VoxelBuffer<T> slice(int z) AVoxelBuffercorresponding to a particular z-slice.voidSubtracts all voxel-values from the maximum value associated with the data-type.
-
Constructor Details
-
VoxelsUntyped
Creates to wrap aVoxelsof unspecified type.- Parameters:
voxels- the voxels to wrap, whose memory is reused without duplication.
-
-
Method Details
-
any
Exposes without any specific buffer type.- Returns:
- the current object, without typing on the buffer.
-
checkIdenticalDataType
Do the voxels have a data-type that is equal tomatch?- Parameters:
match- the data-type the voxel must equal.- Returns:
- true iff the voxel data-type is equal.
-
asByte
Casts to use aUnsignedByteBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.- Returns:
- the cast voxels.
-
asShort
Casts to use aUnsignedShortBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.- Returns:
- the cast voxels.
-
asInt
Casts to use aUnsignedIntBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.- Returns:
- the cast voxels.
-
asFloat
Casts to use aFloatBufferif the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException.- Returns:
- the cast voxels.
-
getVoxelDataType
The underlying data-type of the voxels, represented by aVoxelDataTypeinstance.- Returns:
- an instance of
VoxelDataType.
-
copyVoxelsTo
public void copyVoxelsTo(BoundingBox boxSource, VoxelsUntyped destination, BoundingBox boxDestination) Copies the voxels into adestination, 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 adestination, but only those voxels inside anObjectMask.- 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
vis updated to becomemaxDataTypeValue - 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 insourceVoxelsto copy from.duplicate- if true, the source slice is duplicated before being assigned. Otherwise it is reused.
-
slice
AVoxelBuffercorresponding to a particular z-slice.- Parameters:
z- the index (beginning at 0) of all z-slices.- Returns:
- the corresponding buffer for
z.
-
extent
The size of the voxels across three dimensions.- Returns:
- the size.
-
arithmetic
Interface that allows manipulation of voxel intensities via arithmetic operations.- Returns:
- the interface.
-
assignValue
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
Interface that allows read/copy/duplication operations to be performed regarding the voxels intensities.- Returns:
- the interface.
-