Class DisplayStack
Object
DisplayStack
Stack that contains 1 or 3 channels so that we and display it as either grayscale or as an RGB
unsigned 8-bit image, respectively.
A converter is optionally associated with each channel, used to convert the source images into unsigned 8-bit.
When only two channels are present, one particular channel (with index=1) is left blank.
- Author:
- Owen Feehan
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Index of channel to leave blank when there are only two channels. 0=first, 1=second, 2=third. -
Constructor Summary
ConstructorsConstructorDescriptionDisplayStack
(Stack stack) Create for a particularStack
where all channels are already guaranteed to be unsigned-bit.DisplayStack
(Stack stack, boolean eventuallyThree, Function<VoxelDataType, ChannelConverterAttached<Channel, UnsignedByteBuffer>> createConverter) Create for a particularStack
that may needed to be converted. -
Method Summary
Modifier and TypeMethodDescriptionvoid
copyPixelsTo
(int channelIndex, BoundingBox sourceBox, Voxels<UnsignedByteBuffer> destinationVoxels, BoundingBox destinationBox) Copies pixels from a particular channel to an output buffer.createChannel
(int index, boolean alwaysNew) CreateChannel
for a particularindex
after applying conversion.deriveStack
(boolean alwaysNew) Derives aStack
from the display-stack that will be converted to 8-bit if necessary.The dimensions of all channels in the stack.extent()
The width and height and depth of all channels in theStack
.extractChannelForBoundingBox
(int index, BoundingBox box) extractSlice
(int z) Extract a particular z-slice from theDisplayStack
as a new stack, applying any applicable conversion.A list of optional converters that will be applied to the respective channel instack
if they exist.final int
The number of channels in the stack.getStack()
The underlying stack that will be displayed, possibly after conversion.int
getUnconvertedVoxelAt
(int channelIndex, Point3i point) Retrieve the intensity of a voxel at a particular point, before any conversion is applied.boolean
isRGB()
Does the display-stack contain an RGB image?Creates a Maximum Intensity Projection of each channel.Resolution of voxels to physical measurements.The data-type of the underlying voxels before they are converted to 8-bit.
-
Field Details
-
CHANNEL_TO_SKIP_WHEN_TWO
public static final int CHANNEL_TO_SKIP_WHEN_TWOIndex of channel to leave blank when there are only two channels. 0=first, 1=second, 2=third.- See Also:
-
-
Constructor Details
-
DisplayStack
Create for a particularStack
where all channels are already guaranteed to be unsigned-bit.- Parameters:
stack
- the stack to display.
-
DisplayStack
public DisplayStack(Stack stack, boolean eventuallyThree, Function<VoxelDataType, ChannelConverterAttached<Channel, throws CreateExceptionUnsignedByteBuffer>> createConverter) Create for a particularStack
that may needed to be converted.- Parameters:
stack
- the stack to display.eventuallyThree
- when true, the stack will eventually have three channels. when false, it will have one.createConverter
- creates any necessary converter to map it to unsigned 8 bit.- Throws:
CreateException
- if unable to convert aChannel
.
-
-
Method Details
-
isRGB
public boolean isRGB()Does the display-stack contain an RGB image?- Returns:
- true if the contained image is RGB, false if it is grayscale.
-
dimensions
The dimensions of all channels in the stack.- Returns:
- the dimensions.
-
extent
The width and height and depth of all channels in theStack
.i.e. the size of each of the three possible dimensions.
- Returns:
- the extent.
-
getNumberChannels
public final int getNumberChannels()The number of channels in the stack.- Returns:
- the number of channels.
-
resolution
Resolution of voxels to physical measurements.e.g. physical size of each voxel in a particular dimension.
- Returns:
- the resolution.
-
createChannel
CreateChannel
for a particularindex
after applying conversion. -
extractChannelForBoundingBox
Creates a newChannel
that refers to only aBoundingBox
portion of theDisplayStack
.Existing voxels are always duplicated, and never reused.
- Parameters:
index
- the index of the channel.box
- the bounding-box portion to extract.- Returns:
- a newly created
Channel
containing extracted voxels, corresponding tobox
.
-
deriveStack
Derives aStack
from the display-stack that will be converted to 8-bit if necessary.- Parameters:
alwaysNew
- iff true channels are always created new during conversion, otherwise only if needed.- Returns:
- a stack with either 1 or 3 channels (depending on what's passed into display-stack), all of which are unsigned 8-bit.
-
copyPixelsTo
public void copyPixelsTo(int channelIndex, BoundingBox sourceBox, Voxels<UnsignedByteBuffer> destinationVoxels, BoundingBox destinationBox) Copies pixels from a particular channel to an output buffer.- Parameters:
channelIndex
- the index of the source channel to copy from.sourceBox
- the bounding-box in the source channel to copy from.destinationVoxels
- where to copy the pixels to.destinationBox
- the bounding-box in the destination channel to copy to.
-
unconvertedDataType
The data-type of the underlying voxels before they are converted to 8-bit.- Returns:
- the data-type if all channels have identical data-type, or
Optional.empty()
if they vary.
-
getUnconvertedVoxelAt
Retrieve the intensity of a voxel at a particular point, before any conversion is applied.- Parameters:
channelIndex
- the index of the channel in which the voxel resides.point
- the point in the channel corresponding to the voxel.- Returns:
- the intensity value, before any conversion.
-
projectMax
Creates a Maximum Intensity Projection of each channel.Note that if the channels do not need projections, the existing
Channel
is reused in the newly createdStack
. But if a projection is needed, it is always freshly created as a new channel. -
extractSlice
Extract a particular z-slice from theDisplayStack
as a new stack, applying any applicable conversion.The existing voxels may be reused, if no conversion needs to be applied.
- Parameters:
z
- the index in the Z-dimension of the slice to extract.- Returns:
- the extracted slice, as a new
DisplayStack
after any applicable conversion. - Throws:
CreateException
- if a channel cannot be attached to a converter.
-
getStack
The underlying stack that will be displayed, possibly after conversion. -
getConverters
A list of optional converters that will be applied to the respective channel instack
if they exist.
-