Class Channel

Object
Channel

public class Channel extends Object
A channel from an image.

This is one of the key image-processing classes in Anchor. An image may have one channel (grayscale) or several. Channels of identical size can be bundled together to form a Stack.

The channel's voxels have an underlying data-type that is not exposed as a templated parameter, but can be accessed via getVoxelDataType(). This is deliberate weak-typing.

Each channel has an associated size and optionally defines a physical size for each voxel, as stored in the associated Dimensions structure.

Author:
Owen Feehan
  • Constructor Details

    • Channel

      public Channel(Voxels<?> voxels, Optional<Resolution> resolution)
      Creates for particular voxels and resolution.
      Parameters:
      voxels - the voxels.
      resolution - the resolution, if it is known.
  • Method Details

    • equalMask

      public ObjectMask equalMask(BoundingBox box, int equalValue)
      Creates a ObjectMask representing all the voxels in box equal to equalValue.

      The equal values in the box are assigned an on state, and all other values an off state.

      Parameters:
      box - the bounding-box to consider voxels within, and which forms the bounding-box for the created ObjectMask.
      equalValue - the value voxels must be equal to, so to be assigned an on state in the ObjectMask.
      Returns:
      a newly created ObjectMask as per above.
    • voxels

      public VoxelsUntyped voxels()
      The underlying voxels in the channel.
      Returns:
      the voxels, wrapped in a class that facilitates friendly conversion.
    • replaceVoxels

      public void replaceVoxels(Voxels<?> voxelsToAssign) throws IncorrectImageSizeException
      Assigns new voxels to replace the existing voxels.
      Parameters:
      voxelsToAssign - voxels to be assigned.
      Throws:
      IncorrectImageSizeException - if voxelsToAssign has a different size to the dimensions of the channel.
    • extractSlice

      public Channel extractSlice(int sliceIndex)
      Creates a new Channel containing only one particular slice.

      The existing Voxels are reused, without creating new buffers.

      Parameters:
      sliceIndex - the index of the slice to extract (index in z-dimension).
      Returns:
      a newly created Channel consisting of the slice at sliceIndex only.
    • scaleXY

      public Channel scaleXY(ScaleFactor scaleFactor, VoxelsResizer resizer)
      Resizes the dimensions of the channel, by scaling the existing size by a factor.

      Existing voxel values are interpolated to match the new size.

      This is useful for quickly downscaling or upscaling by a particular factor.

      It is an immutable operation, and the existing object state remains unchanged.

      The z-dimension remains unchanged.

      Parameters:
      scaleFactor - the scaling-factor to be applied to the sizes.
      resizer - an interpolator for resizing voxels.
      Returns:
      a newly created Channel containing a resized version of the current.
    • resizeXY

      public Channel resizeXY(Extent extentToAssign, VoxelsResizer resizer)
      Resizes the dimensions of the channel, interpolating the existing voxel values to match.

      It is an immutable operation, and the existing object state remains unchanged.

      The z-dimension remains unchanged.

      Parameters:
      extentToAssign - the new size to assign. The z-component is ignored.
      resizer - an interpolator for resizing voxels.
      Returns:
      a newly created Channel containing a resized version of the current.
    • resizeXY

      public Channel resizeXY(int x, int y, VoxelsResizer resizer)
      Like resizeXY(Extent, VoxelsResizer) but specifies the size via int parameters.
      Parameters:
      x - the size along the x-axis.
      y - the size along the y-axis.
      resizer - an interpolator for resizing voxels.
      Returns:
      a newly created Channel containing a resized version of the current.
    • projectMax

      public Channel projectMax()
      A maximum-intensity projection across the z-slices.
      Returns:
      a newly created Channel with a newly created voxel-buffer.
    • projectMean

      public Channel projectMean()
      A mean-intensity projection across the z-slices.
      Returns:
      a newly created Channel with a newly created voxel-buffer.
    • duplicate

      public Channel duplicate()
      A deep-copy.
      Returns:
      newly created deep-copy.
    • voxelsEqualTo

      public VoxelsPredicate voxelsEqualTo(int equalToValue)
      Operations on whether particular voxels are equal to a particular value.
      Parameters:
      equalToValue - the value all voxels should be equal to.
      Returns:
      a newly instantiated object to perform queries on voxels who fulfill the above condition.
    • voxelsGreaterThan

      public VoxelsPredicate voxelsGreaterThan(int threshold)
      Operations on whether particular voxels are greater than a threshold (but not equal to).
      Parameters:
      threshold - voxel-values greater than this threshold are included.
      Returns:
      a newly instantiated object to perform queries on voxels who fulfill the above condition.
    • assignResolution

      public void assignResolution(Optional<Resolution> resolution)
      Assigns a new resolution.

      This is a mutable operation that replaces existing state.

      Parameters:
      resolution - the resolution to assign.
    • getVoxelDataType

      public VoxelDataType getVoxelDataType()
      The underlying data-type of the voxels in the channel, represented by a VoxelDataType instance.
      Returns:
      an instance of VoxelDataType.
    • toString

      public String toString()
      A string representation of a histogram of voxel-intensities in the channel.
      Overrides:
      toString in class Object
    • equalsDeep

      public boolean equalsDeep(Channel other, boolean compareResolution)
      Are the two channels equal using a deep voxel by voxel comparison?
      Parameters:
      other - the channel to compare with.
      compareResolution - if true, image-resolution must also be equal, otherwise it is not compared.
      Returns:
      true if they are deemed equal, false otherwise.
    • arithmetic

      public VoxelsArithmetic arithmetic()
      Interface that allows manipulation of voxel intensities via arithmetic operations.
      Returns:
      the interface.
    • assignValue

      public VoxelsAssigner assignValue(int valueToAssign)
      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

      public VoxelsExtracter<?> extract()
      Interface that allows read/copy/duplication operations to be performed regarding the voxels intensities.
      Returns:
      the interface.
    • extent

      public Extent extent()
      The size of the voxels across three dimensions.
      Returns:
      the size.
    • resolution

      public Optional<Resolution> resolution()
      The resolution of the voxel that describes a physical size for each voxel.
      Returns:
      the resolution, if it exists.
    • dimensions

      public Dimensions dimensions()
      The size and voxel-resolution of the channel.