Class Mask
This is one of Anchor's core data-objects.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a mask from an existing channel using default values for off (0) and on (255).Mask
(Channel channel, BinaryValuesInt binaryValues) Creates a mask from an existing channel.Mask
(Dimensions dimensions, BinaryValuesInt binaryValues) Creates a new empty mask of particular dimensions and with particularBinaryValuesInt
.Mask
(BinaryVoxels<UnsignedByteBuffer> voxels) Creates a mask from an existing binary-voxels using default image resolution.Mask
(BinaryVoxels<UnsignedByteBuffer> voxels, Optional<Resolution> resolution) Creates a mask from an existing binary-voxels and a specific image resolution. -
Method Summary
Modifier and TypeMethodDescriptionInterface that allows assignment of an off state to all or subsets of the voxels.assignOn()
Interface that allows assignment of an on state to all or subsets of the voxels.The two states which are permitted to be assigned to the voxels, stored as bytes.The two states which are permitted to be assigned to the voxels, stored as unsigned ints.The underlying voxels in the mask, exposed asBinaryVoxels
.channel()
The underlying channel which contains the binary-values.The size and voxel-resolution of the channel.Deep-copies the object.boolean
extent()
The size of the voxels across three dimensions.extractSlice
(int z) Creates a newMask
containing only one particular slice.flattenZ()
Creates an otherwise identicalMask
but a maximum-intensity-projection applied to the z-dimension.int
hashCode()
boolean
Does a particular voxel have the on state?region
(BoundingBox box, boolean reuseIfPossible) Creates anObjectMask
corresponding to the on/off state in a bounding-box.void
replaceBy
(BinaryVoxels<UnsignedByteBuffer> voxels) Replaces the underlying voxels in the mask with new voxels.Resolution of voxels to physical measurements.scaleXY
(ScaleFactor scaleFactor) Creates a newMask
whose X- and Y- dimensions are scaled byscaleFactor
.sliceBuffer
(int z) A buffer corresponding to a particular z-slice.voxels()
The underlying voxels in the mask.Operations on whether particular voxels are off.voxelsOn()
Operations on whether particular voxels are on.
-
Constructor Details
-
Mask
Creates a mask from an existing channel using default values for off (0) and on (255).The channel should have maximally two distinct intensity values, represeting off and on states.
Precondition: no check occurs that only off and on voxels exist in a channel, so please call only with valid input.
- Parameters:
channel
- the channel to form the mask, whose voxel-buffer is reused internally in the mask
-
Mask
Creates a mask from an existing channel.The channel should have maximally two distinct intensity values, represeting off and ON states.
Precondition: no check occurs that only off and on voxels exist in a channel, so please call only with valid input.
- Parameters:
channel
- the channel to form the mask, whose voxel-buffer is reused internally in the maskbinaryValues
- how to identify the off and on states from intensity voxel-values
-
Mask
Creates a mask from an existing binary-voxels using default image resolution.- Parameters:
voxels
- theBinaryVoxels
to be reused as the internal buffer of the mask
-
Mask
Creates a mask from an existing binary-voxels and a specific image resolution.- Parameters:
voxels
- the binary-voxels to be reused as the internal buffer of the mask.resolution
- the image-resolution to assign.
-
Mask
Creates a new empty mask of particular dimensions and with particularBinaryValuesInt
.Default mask values for off (0) and on (255) are employed.
- Parameters:
dimensions
- the dimensions for the newly-created mask.binaryValues
- the binary-values to use for the newly created mask.
-
-
Method Details
-
dimensions
The size and voxel-resolution of the channel.- Returns:
- the dimensions.
-
resolution
Resolution of voxels to physical measurements.e.g. physical size of each voxel in a particular dimension.
- Returns:
- the image-resolution.
-
voxels
The underlying voxels in the mask.- Returns:
- the voxels.
-
binaryVoxels
The underlying voxels in the mask, exposed asBinaryVoxels
.- Returns:
- the voxels, with associated binary-values.
-
isVoxelOn
Does a particular voxel have the on state?- Parameters:
point
- the point indicating which voxel to check.- Returns:
- true if this voxel has an on state, false otherwise.
-
duplicate
Deep-copies the object.- Returns:
- a deep-copy of the current object.
-
region
Creates anObjectMask
corresponding to the on/off state in a bounding-box.- Parameters:
box
- the bounding-box.reuseIfPossible
- if true, the existing boxels will be reused if possible (e.g. if the box refers to the entire image). if false, new voxel memory will always be allocated.- Returns:
- the derived
ObjectMask
.
-
flattenZ
Creates an otherwise identicalMask
but a maximum-intensity-projection applied to the z-dimension.- Returns:
- a newly created mask, as above.
-
voxelsOn
Operations on whether particular voxels are on.- Returns:
- a newly instantiated object to perform queries on voxels who fulfill the above condition.
-
voxelsOff
Operations on whether particular voxels are off.- Returns:
- a newly instantiated object to perform queries on voxels who fulfill the above condition.
-
scaleXY
Creates a newMask
whose X- and Y- dimensions are scaled byscaleFactor
. -
extractSlice
Creates a newMask
containing only one particular slice.The existing
Voxels
are reused, without creating new buffers.- Parameters:
z
- the index of the slice to extract (index in z-dimension)- Returns:
- a newly created
Mask
consisting of the slice atsliceIndex
only.
-
replaceBy
Replaces the underlying voxels in the mask with new voxels.The resolution and binary-values remain unchanged.
- Parameters:
voxels
- the new voxels to assign.- Throws:
IncorrectImageSizeException
- if the size ofvoxels
is not identical to the existing boxels.
-
assignOn
Interface that allows assignment of an on state to all or subsets of the voxels.- Returns:
- the interface.
-
assignOff
Interface that allows assignment of an off state to all or subsets of the voxels.- Returns:
- the interface.
-
sliceBuffer
A buffer corresponding to a particular z-slice.This buffer is either a NIO class or another class that wraps the underlying array storing voxel intensities.
- Parameters:
z
- the index (beginning at 0) of all z-slices.- Returns:
- the corresponding buffer for
z
.
-
equals
-
hashCode
public int hashCode() -
extent
The size of the voxels across three dimensions.- Returns:
- the size.
-
channel
The underlying channel which contains the binary-values. It is always has data-type of unsigned 8-bit. -
binaryValuesInt
The two states which are permitted to be assigned to the voxels, stored as unsigned ints. -
binaryValuesByte
The two states which are permitted to be assigned to the voxels, stored as bytes.
-