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 aVoxels
of 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 aUnsignedByteBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.asFloat()
Casts to use aFloatBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.asInt()
Casts to use aUnsignedIntBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.asShort()
Casts to use aUnsignedShortBuffer
if 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
?void
copyVoxelsTo
(ObjectMask objectSource, VoxelsUntyped destination, BoundingBox boxDestination) Copies the voxels into adestination
, but only those voxels inside anObjectMask
.void
copyVoxelsTo
(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 aVoxelDataType
instance.void
replaceSlice
(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) AVoxelBuffer
corresponding to a particular z-slice.void
Subtracts all voxel-values from the maximum value associated with the data-type.
-
Constructor Details
-
VoxelsUntyped
Creates to wrap aVoxels
of 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 aUnsignedByteBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.- Returns:
- the cast voxels.
-
asShort
Casts to use aUnsignedShortBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.- Returns:
- the cast voxels.
-
asInt
Casts to use aUnsignedIntBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.- Returns:
- the cast voxels.
-
asFloat
Casts to use aFloatBuffer
if the voxels contain this data-type, otherwise throws aIncorrectVoxelTypeException
.- Returns:
- the cast voxels.
-
getVoxelDataType
The underlying data-type of the voxels, represented by aVoxelDataType
instance.- 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
v
is 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 insourceVoxels
to copy from.duplicate
- if true, the source slice is duplicated before being assigned. Otherwise it is reused.
-
slice
AVoxelBuffer
corresponding 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.
-