Class DisplayStack

Object
DisplayStack

public class DisplayStack extends Object
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 Details

    • CHANNEL_TO_SKIP_WHEN_TWO

      public static final int CHANNEL_TO_SKIP_WHEN_TWO
      Index of channel to leave blank when there are only two channels. 0=first, 1=second, 2=third.
      See Also:
  • Constructor Details

    • DisplayStack

      public DisplayStack(Stack stack)
      Create for a particular Stack 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,UnsignedByteBuffer>> createConverter) throws CreateException
      Create for a particular Stack 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 a Channel.
  • 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

      public Dimensions dimensions()
      The dimensions of all channels in the stack.
      Returns:
      the dimensions.
    • extent

      public Extent extent()
      The width and height and depth of all channels in the Stack.

      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

      public Optional<Resolution> resolution()
      Resolution of voxels to physical measurements.

      e.g. physical size of each voxel in a particular dimension.

      Returns:
      the resolution.
    • createChannel

      public Channel createChannel(int index, boolean alwaysNew)
      Create Channel for a particular index after applying conversion.
      Parameters:
      index - the index of the channel in the Stack to create a converted version of.
      alwaysNew - if true, a new channel is always created. Otherwise it is created, only if needs be.
      Returns:
      the Channel after extracting from the stack and applying conversion.
    • extractChannelForBoundingBox

      public Channel extractChannelForBoundingBox(int index, BoundingBox box)
      Creates a new Channel that refers to only a BoundingBox portion of the DisplayStack.

      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 to box.
    • deriveStack

      public Stack deriveStack(boolean alwaysNew)
      Derives a Stack 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

      public Optional<VoxelDataType> 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

      public int getUnconvertedVoxelAt(int channelIndex, Point3i point)
      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

      public DisplayStack 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 created Stack. But if a projection is needed, it is always freshly created as a new channel.

      Returns:
      a newly created Stack, with maximum intensity projections of each Channel.
    • extractSlice

      public DisplayStack extractSlice(int z) throws CreateException
      Extract a particular z-slice from the DisplayStack 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

      public Stack 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 in stack if they exist.