public class Channel extends Object
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.
Constructor and Description |
---|
Channel(Voxels<?> voxels,
Optional<Resolution> resolution)
Creates for particular voxels and resolution.
|
Modifier and Type | Method and Description |
---|---|
VoxelsArithmetic |
arithmetic()
Interface that allows manipulation of voxel intensities via arithmetic operations.
|
void |
assignResolution(Optional<Resolution> resolution)
Assigns a new resolution.
|
VoxelsAssigner |
assignValue(int valueToAssign)
Interface that allows assignment of a particular value to all or subsets of the voxels.
|
Dimensions |
dimensions()
The size and voxel-resolution of the channel.
|
Channel |
duplicate()
A deep-copy.
|
ObjectMask |
equalMask(BoundingBox box,
int equalValue)
|
boolean |
equalsDeep(Channel other,
boolean compareResolution)
Are the two channels equal using a deep voxel by voxel comparison?
|
Extent |
extent()
The size of the voxels across three dimensions.
|
VoxelsExtracter<?> |
extract()
Interface that allows read/copy/duplication operations to be performed regarding the voxels
intensities.
|
Channel |
extractSlice(int sliceIndex)
Creates a new
Channel containing only one particular slice. |
VoxelDataType |
getVoxelDataType()
The underlying data-type of the voxels in the channel, represented by a
VoxelDataType
instance. |
Channel |
projectMax()
A maximum-intensity
projection across the z-slices.
|
Channel |
projectMean()
A mean-intensity projection across the z-slices.
|
void |
replaceVoxels(Voxels<?> voxelsToAssign)
Assigns new voxels to replace the existing voxels.
|
Channel |
resizeXY(Extent extentToAssign,
VoxelsResizer resizer)
Resizes the dimensions of the channel, interpolating the existing voxel values to match.
|
Channel |
resizeXY(int x,
int y,
VoxelsResizer resizer)
Like
resizeXY(Extent, VoxelsResizer) but specifies the size via int
parameters. |
Optional<Resolution> |
resolution()
The resolution of the voxel that describes a physical size for each voxel.
|
Channel |
scaleXY(ScaleFactor scaleFactor,
VoxelsResizer resizer)
Resizes the dimensions of the channel, by scaling the existing size by a factor.
|
String |
toString()
A string representation of a histogram of voxel-intensities in the channel.
|
VoxelsUntyped |
voxels()
The underlying voxels in the channel.
|
VoxelsPredicate |
voxelsEqualTo(int equalToValue)
Operations on whether particular voxels are equal to a particular value.
|
VoxelsPredicate |
voxelsGreaterThan(int threshold)
Operations on whether particular voxels are greater than a threshold (but not equal to).
|
public Channel(Voxels<?> voxels, Optional<Resolution> resolution)
voxels
- the voxels.resolution
- the resolution, if it is known.public ObjectMask equalMask(BoundingBox box, int equalValue)
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.
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
.ObjectMask
as per above.public VoxelsUntyped voxels()
public void replaceVoxels(Voxels<?> voxelsToAssign) throws IncorrectImageSizeException
voxelsToAssign
- voxels to be assigned.IncorrectImageSizeException
- if voxelsToAssign
has a different size to the
dimensions of the channel.public Channel extractSlice(int sliceIndex)
Channel
containing only one particular slice.
The existing Voxels
are reused, without creating new buffers.
sliceIndex
- the index of the slice to extract (index in z-dimension).Channel
consisting of the slice at sliceIndex
only.public Channel scaleXY(ScaleFactor scaleFactor, VoxelsResizer resizer)
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.
scaleFactor
- the scaling-factor to be applied to the sizes.resizer
- an interpolator for resizing voxels.Channel
containing a resized version of the current.public Channel resizeXY(Extent extentToAssign, VoxelsResizer resizer)
It is an immutable operation, and the existing object state remains unchanged.
The z-dimension remains unchanged.
extentToAssign
- the new size to assign. The z-component is ignored.resizer
- an interpolator for resizing voxels.Channel
containing a resized version of the current.public Channel resizeXY(int x, int y, VoxelsResizer resizer)
resizeXY(Extent, VoxelsResizer)
but specifies the size via int
parameters.x
- the size along the x-axis.y
- the size along the y-axis.resizer
- an interpolator for resizing voxels.Channel
containing a resized version of the current.public Channel projectMax()
Channel
with a newly created voxel-buffer.public Channel projectMean()
Channel
with a newly created voxel-buffer.public Channel duplicate()
public VoxelsPredicate voxelsEqualTo(int equalToValue)
equalToValue
- the value all voxels should be equal to.public VoxelsPredicate voxelsGreaterThan(int threshold)
threshold
- voxel-values greater than this threshold are included.public void assignResolution(Optional<Resolution> resolution)
This is a mutable operation that replaces existing state.
resolution
- the resolution to assign.public VoxelDataType getVoxelDataType()
VoxelDataType
instance.VoxelDataType
.public String toString()
public boolean equalsDeep(Channel other, boolean compareResolution)
other
- the channel to compare with.compareResolution
- if true, image-resolution must also be equal, otherwise it is not
compared.public VoxelsArithmetic arithmetic()
public VoxelsAssigner assignValue(int valueToAssign)
valueToAssign
- the value to assign.public VoxelsExtracter<?> extract()
public Extent extent()
public Optional<Resolution> resolution()
public Dimensions dimensions()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.