Class RGBStack
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionCreate withChannel
s for each color.RGBStack
(Dimensions dimensions, ChannelFactorySingleType factory) Creates a particularly-sized stack with all channels initialized to 0.Creates from an existing stack (which must have 1 or 3 channels).Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to 0.Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to a specificColor
.Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to a specificRGBColor
.RGBStack
(Extent extent, ChannelFactorySingleType factory) Creates a particularly-sized stack with all channels initialized to 0. -
Method Summary
Modifier and TypeMethodDescriptionboolean
allChannelsHaveType
(VoxelDataType channelDataType) Determines if all channels have a specific data-type.void
assignAllVoxels
(RGBColor color) Assigns aRGBColor
to all voxels in the respective channels.void
assignVoxel
(Point3i point, RGBColor color) Assigns aRGBColor
to a single voxel in the respective channels.asStack()
Exposes the underlying stack, storing the three RGB channels in respective order.blue()
The blue channel.colorAtVoxel
(ReadableTuple3i point) Gets the color at a particular voxel.The dimensions of all channels in the stack.A deep copy.extent()
The width and height and depth of the image.extractSlice
(int z) Extract a particular z-slice from theStack
as a new stack.getChannel
(int index) Returns the channel at a particular position in the stack.green()
The green channel.iterator()
Produces a new stack with a particular mapping applied to each channel.objectWithColor
(RGBColor color) Extracts anObjectMask
from aChannel
of all voxels that have a particular color.red()
The red channel.sliceBuffer
(int channelIndex, int zIndex) A buffer corresponding to a particular z-slice of a particular channel.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RGBStack
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to 0.- Parameters:
extent
- size of each channel.
-
RGBStack
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to a specificColor
.- Parameters:
extent
- size of each channel.color
- the color to assign to all voxels.
-
RGBStack
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels initialized to a specificRGBColor
.- Parameters:
extent
- size of each channel.color
- the color to assign to all voxels.
-
RGBStack
Creates a particularly-sized stack with all channels initialized to 0.- Parameters:
extent
- size of each channel.factory
- factory to create the channel.
-
RGBStack
Creates a particularly-sized stack with all channels initialized to 0.- Parameters:
dimensions
- dimensions of each channel.factory
- factory to create the channel.
-
RGBStack
Creates from an existing stack (which must have 1 or 3 channels).The channel order is: red, green, blue.
A single channel is treated as grayscale, and duplicated to form red, green, blue channels.
- Parameters:
stack
- the stack.
-
RGBStack
Create withChannel
s for each color.- Parameters:
red
- the red channel.green
- the green channel.blue
- the blue channel.- Throws:
IncorrectImageSizeException
- if the channels are not uniformly sized.
-
-
Method Details
-
mapChannel
public RGBStack mapChannel(CheckedUnaryOperator<Channel, OperationFailedException> mapping) throws OperationFailedExceptionProduces a new stack with a particular mapping applied to each channel.The function applied to the channel should ensure it produces uniform sizes.
- Parameters:
mapping
- performs an operation on a channel and produces a modified channel (or a different one entirely).- Returns:
- a new stack (after any modification by
mapping
) preserving the channel order. - Throws:
OperationFailedException
- if the channels produced have non-uniform sizes.
-
red
The red channel.- Returns:
- the red channel.
-
green
The green channel.- Returns:
- the green channel.
-
blue
The blue channel.- Returns:
- the blue channel.
-
getChannel
Returns the channel at a particular position in the stack.- Parameters:
index
- the index (zero-indexed).- Returns:
- the respective channel.
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
dimensions
The dimensions of all channels in the stack.- Returns:
- the dimensions.
-
extractSlice
Extract a particular z-slice from theStack
as a new stack.- Parameters:
z
- the index in the Z-dimension of the slice to extract.- Returns:
- the extracted slice, as a new
Stack
but reusing the existing voxels.
-
asStack
Exposes the underlying stack, storing the three RGB channels in respective order.- Returns:
- the stack.
-
duplicate
A deep copy.- Returns:
- a deep copy of the current instance.
-
allChannelsHaveType
Determines if all channels have a specific data-type.- Parameters:
channelDataType
- the specific data-type.- Returns:
- true iff all channels have
channelDataType
as their voxel data-type.
-
assignVoxel
Assigns aRGBColor
to a single voxel in the respective channels.- Parameters:
point
- identifies which voxel to assign the color value to.color
- the color.- Throws:
IllegalArgumentException
- if the stack has a channel that is notUnsignedByteVoxelType
.
-
assignAllVoxels
Assigns aRGBColor
to all voxels in the respective channels.- Parameters:
color
- the color.- Throws:
IllegalArgumentException
- if the stack has a channel that is notUnsignedByteVoxelType
.
-
colorAtVoxel
Gets the color at a particular voxel.Note that it is inefficient to call this method on voxels repeatedly, as it is heavy on memory allocation on the heap, and makes inefficient usage of buffer iteration. A new
RGBColor
is created with each call. Prefer iterating the voxels viagetChannel(int)
.- Parameters:
point
- locates the voxel (zero-indexed) in the stack.- Returns:
- a newly created
RGBColor
, indicating the color at a particular voxel.
-
objectWithColor
Extracts anObjectMask
from aChannel
of all voxels that have a particular color.This operation is only supported when all channels have type unsigned-byte.
The bounding-box of the created
ObjectMask
will fit the voxels as maximally tightly as possible.- Parameters:
color
- the color to search for.- Returns:
- an
ObjectMask
describing all voxels with this color, if any exist. If no exist, thenOptional.empty()
. - Throws:
OperationFailedException
- if any channel has a data-type other than unsigned-byte.
-
extent
The width and height and depth of the image.i.e. the size of each of the three possible dimensions.
- Returns:
- the extent.
-
sliceBuffer
A buffer corresponding to a particular z-slice of a particular channel.This buffer is either a NIO class or another class that wraps the underlying array storing voxel intensities.
- Parameters:
channelIndex
- the index (beginning at 0) of the respective channel.zIndex
- the index (beginning at 0) of the respective z-slice.- Returns:
- the corresponding buffer for
z
.
-
iterator
-