Constructor and Description |
---|
RGBStack(Channel red,
Channel green,
Channel blue)
Create with
Channel s for each color. |
RGBStack(Dimensions dimensions,
ChannelFactorySingleType factory)
Creates a particularly-sized stack with all channels initialized to 0.
|
RGBStack(Extent extent)
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels
initialized to 0.
|
RGBStack(Extent extent,
ChannelFactorySingleType factory)
Creates a particularly-sized stack with all channels initialized to 0.
|
RGBStack(Extent extent,
Color color)
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels
initialized to a specific
Color . |
RGBStack(Extent extent,
RGBColor color)
Creates a particularly-sized stack with unsigned byte voxel data type, with all voxels
initialized to a specific
RGBColor . |
RGBStack(Stack stack)
Creates from an existing stack (which must have 1 or 3 channels).
|
Modifier and Type | Method and Description |
---|---|
boolean |
allChannelsHaveType(VoxelDataType channelDataType)
Determines if all channels have a specific data-type.
|
void |
assignAllVoxels(RGBColor color)
Assigns a
RGBColor to all voxels in the respective channels. |
void |
assignVoxel(Point3i point,
RGBColor color)
Assigns a
RGBColor to a single voxel in the respective channels. |
Stack |
asStack()
Exposes the underlying stack, storing the three RGB channels in respective order.
|
Channel |
blue()
The blue channel.
|
RGBColor |
colorAtVoxel(ReadableTuple3i point)
Gets the color at a particular voxel.
|
Dimensions |
dimensions()
The dimensions of all channels in the stack.
|
RGBStack |
duplicate()
A deep copy.
|
Extent |
extent()
The width and height and depth of the image.
|
RGBStack |
extractSlice(int z)
Extract a particular z-slice from the
Stack as a new stack. |
Channel |
getChannel(int index)
Returns the channel at a particular position in the stack.
|
Channel |
green()
The green channel.
|
Iterator<Channel> |
iterator() |
RGBStack |
mapChannel(CheckedUnaryOperator<Channel,OperationFailedException> mapping)
Produces a new stack with a particular mapping applied to each channel.
|
Optional<ObjectMask> |
objectWithColor(RGBColor color)
Extracts an
ObjectMask from a Channel of all voxels that have a particular
color. |
Channel |
red()
The red channel.
|
UnsignedByteBuffer |
sliceBuffer(int channelIndex,
int zIndex)
A buffer corresponding to a particular z-slice of a particular channel.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEach, spliterator
public RGBStack(Extent extent)
extent
- size of each channel.public RGBStack(Extent extent, Color color)
Color
.extent
- size of each channel.color
- the color to assign to all voxels.public RGBStack(Extent extent, RGBColor color)
RGBColor
.extent
- size of each channel.color
- the color to assign to all voxels.public RGBStack(Extent extent, ChannelFactorySingleType factory)
extent
- size of each channel.factory
- factory to create the channel.public RGBStack(Dimensions dimensions, ChannelFactorySingleType factory)
dimensions
- dimensions of each channel.factory
- factory to create the channel.public RGBStack(Stack stack)
The channel order is: red, green, blue.
A single channel is treated as grayscale, and duplicated to form red, green, blue channels.
stack
- the stack.public RGBStack(Channel red, Channel green, Channel blue) throws IncorrectImageSizeException
Channel
s for each color.red
- the red channel.green
- the green channel.blue
- the blue channel.IncorrectImageSizeException
- if the channels are not uniformly sized.public RGBStack mapChannel(CheckedUnaryOperator<Channel,OperationFailedException> mapping) throws OperationFailedException
The function applied to the channel should ensure it produces uniform sizes.
mapping
- performs an operation on a channel and produces a modified channel (or a
different one entirely).mapping
) preserving the channel order.OperationFailedException
- if the channels produced have non-uniform sizes.public Channel red()
public Channel green()
public Channel blue()
public Channel getChannel(int index)
index
- the index (zero-indexed).IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >=
size()
)public Dimensions dimensions()
public RGBStack extractSlice(int z)
Stack
as a new stack.z
- the index in the Z-dimension of the slice to extract.Stack
but reusing the existing voxels.public Stack asStack()
public RGBStack duplicate()
public boolean allChannelsHaveType(VoxelDataType channelDataType)
channelDataType
- the specific data-type.channelDataType
as their voxel data-type.public void assignVoxel(Point3i point, RGBColor color)
RGBColor
to a single voxel in the respective channels.point
- identifies which voxel to assign the color value to.color
- the color.IllegalArgumentException
- if the stack has a channel that is not UnsignedByteVoxelType
.public void assignAllVoxels(RGBColor color)
RGBColor
to all voxels in the respective channels.color
- the color.IllegalArgumentException
- if the stack has a channel that is not UnsignedByteVoxelType
.public RGBColor colorAtVoxel(ReadableTuple3i point)
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 via getChannel(int)
.
point
- locates the voxel (zero-indexed) in the stack.RGBColor
, indicating the color at a particular voxel.public Optional<ObjectMask> objectWithColor(RGBColor color) throws OperationFailedException
ObjectMask
from a Channel
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.
color
- the color to search for.ObjectMask
describing all voxels with this color, if any exist. If no
exist, then Optional.empty()
.OperationFailedException
- if any channel has a data-type other than unsigned-byte.public Extent extent()
i.e. the size of each of the three possible dimensions.
public UnsignedByteBuffer sliceBuffer(int channelIndex, int zIndex)
This buffer is either a NIO class or another class that wraps the underlying array storing voxel intensities.
channelIndex
- the index (beginning at 0) of the respective channel.zIndex
- the index (beginning at 0) of the respective z-slice.z
.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.