public class LabelImages extends Object
LabelUtils
Modifier | Constructor and Description |
---|---|
protected |
LabelImages()
Private constructor to prevent class instantiation.
|
Modifier and Type | Method and Description |
---|---|
static ij.ImagePlus |
applyLut(ij.ImagePlus labelImage,
double[] values)
Applies the given Look-up table to the input label image.
|
static ij.process.FloatProcessor |
applyLut(ij.process.ImageProcessor labelImage,
double[] values)
Applies the given Look-up table to the input 2D label image.
|
static ij.ImageStack |
applyLut(ij.ImageStack labelImage,
double[] values)
Applies the given Look-up table to the input 3D label image.
|
static ij.process.ImageProcessor |
areaOpening(ij.process.ImageProcessor labelImage,
int nPixelMin)
Applies area opening on a label image: creates a new label image that
contains only particles with at least the specified number of pixels.
|
static ij.process.ImageProcessor |
binarize(ij.process.ImageProcessor image,
int label)
Returns the binary image with value equals to
true only when the corresponding value in the input image equals label . |
static ij.process.ByteProcessor |
createLabelImage(ij.process.ImageProcessor... images)
Creates a new label image from a set of binary images.
|
static ij.process.ImageProcessor |
createLabelImage(int width,
int height,
int nLabels)
Creates a label image with the appropriate class to store the required
number of labels.
|
static ij.ImageStack |
createLabelStack(int width,
int height,
int depth,
int nLabels)
Creates a new image stack with the appropriate class to store the required
number of labels.
|
static ij.ImagePlus |
cropLabel(ij.ImagePlus imagePlus,
int label,
int border)
Returns a binary image that contains only the selected particle or
region, by automatically cropping the image and eventually adding some
borders.
|
static ij.process.ImageProcessor |
cropLabel(ij.process.ImageProcessor image,
int label,
int border)
Returns a binary image that contains only the selected particle or
region, by automatically cropping the image and eventually adding some
borders.
|
static ij.ImageStack |
cropLabel(ij.ImageStack image,
int label,
int border)
Returns a binary image that contains only the selected particle or
region, by automatically cropping the image and eventually adding some
borders.
|
static ij.ImagePlus |
dilateLabels(ij.ImagePlus imagePlus,
double distMax)
Applies a constrained dilation to each region in the 3D label map:
The dilation of each region is constrained by the other regions;
The dilation extent is limited by the specified distance (in voxel
unit)
|
static ij.process.ImageProcessor |
dilateLabels(ij.process.ImageProcessor labelMap,
double radius)
Applies a constrained dilation to each region in the label map:
The dilation of each region is constrained by the other regions;
The dilation extent is given by a radius value (in pixel unit).
|
static ij.ImageStack |
dilateLabels(ij.ImageStack labelMap,
double radius)
Applies a constrained dilation to each region in the 3D label map:
The dilation of each region is constrained by the other regions;
The dilation extent is limited by the the radius value (in voxel
unit).
|
static ij.process.ImageProcessor |
distanceMap(ij.process.ImageProcessor image)
Computes the distance map for each region within a label map.
|
static ij.process.ImageProcessor |
distanceMap(ij.process.ImageProcessor image,
ChamferMask2D mask,
boolean floatingPoint,
boolean normalize)
Computes the distance map for each region within a label map, by
specifying the chamfer mask and the normalization.
|
static ij.process.ImageProcessor |
distanceMap(ij.process.ImageProcessor image,
float[] weights,
boolean normalize)
Computes the distance map from a 3D image of labels
Distance is computed for each label voxel, as the chamfer distance to the
nearest voxel with a different value.
|
static ij.process.ImageProcessor |
distanceMap(ij.process.ImageProcessor image,
short[] weights,
boolean normalize)
Computes the distance map for each region within a label map.
|
static ij.ImageStack |
distanceMap(ij.ImageStack image)
Computes the 3D distance map from an image of labels.
|
static ij.ImageStack |
distanceMap(ij.ImageStack image,
ChamferMask3D mask,
boolean floatingPoint,
boolean normalize)
Computes the 3D distance map from an image of labels, by specifying
the chamfer mask and the normalization.
|
static ij.ImageStack |
distanceMap(ij.ImageStack image,
float[] weights,
boolean normalize)
Computes the distance map from a 3D image of labels
Distance is computed for each label voxel, as the chamfer distance to the
nearest voxel with a different value.
|
static ij.ImageStack |
distanceMap(ij.ImageStack image,
short[] weights,
boolean normalize)
Computes the distance map from a 3D image of labels
Distance is computed for each label voxel, as the chamfer distance to the
nearest voxel with a different value.
|
static int[] |
findAllLabels(ij.ImagePlus image)
Returns the set of unique labels existing in the given image, excluding
the value zero (used for background).
|
static int[] |
findAllLabels(ij.process.ImageProcessor image)
Returns the set of unique labels existing in the given image, excluding
the value zero (used for background).
|
static int[] |
findAllLabels(ij.ImageStack image)
Returns the set of unique labels existing in the given stack, excluding
the value zero (used for background).
|
static int |
findLargestLabel(ij.ImagePlus imagePlus)
Find largest label (by number of pixels/voxels) in input image
|
static Point[] |
findPositionOfMaxValues(ij.process.ImageProcessor valueImage,
ij.process.ImageProcessor labelImage,
int[] labels)
Deprecated.
use LavelValues.findPositionOfMaxValues instead
|
static Point[] |
findPositionOfMinValues(ij.process.ImageProcessor valueImage,
ij.process.ImageProcessor labelImage,
int[] labels)
Deprecated.
use LavelValues.findPositionOfMinValues instead
|
static double |
getDiceCoefficient(ij.ImagePlus labelImage1,
ij.ImagePlus labelImage2)
Get the Dice coefficient between two label images.
|
static double |
getDiceCoefficient(ij.process.ImageProcessor labelImage1,
ij.process.ImageProcessor labelImage2)
Get the Dice coefficient between two label images.
|
static double |
getDiceCoefficient(ij.ImageStack labelImage1,
ij.ImageStack labelImage2)
Get the Dice coefficient between two label images.
|
static ij.measure.ResultsTable |
getDiceCoefficientPerLabel(ij.ImagePlus labelImage1,
ij.ImagePlus labelImage2)
Get the Dice coefficient per label (intersection over union overlap) between
two label images.
|
static ij.measure.ResultsTable |
getDiceCoefficientPerLabel(ij.process.ImageProcessor labelImage1,
ij.process.ImageProcessor labelImage2)
Get the Dice coefficient per label (intersection over union overlap) between
two label images.
|
static ij.measure.ResultsTable |
getDiceCoefficientPerLabel(ij.ImageStack labelImage1,
ij.ImageStack labelImage2)
Get the Dice coefficient per label (intersection over union overlap) between
two label images.
|
static double |
getFalseNegativeError(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the total false negative error between two label images (source and target).
|
static double |
getFalseNegativeError(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the total false negative error between two label images (source and target).
|
static double |
getFalseNegativeError(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the total false negative error between two label images (source and target).
|
static ij.measure.ResultsTable |
getFalseNegativeErrorPerLabel(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the false negative error between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getFalseNegativeErrorPerLabel(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the false negative error between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getFalseNegativeErrorPerLabel(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the false negative error between two label images (source and target)
per each individual labeled region.
|
static double |
getFalsePositiveError(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the total false positive error between two label images (source and target).
|
static double |
getFalsePositiveError(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the total false positive error between two label images (source and target).
|
static double |
getFalsePositiveError(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the total false positive error between two label images (source and target).
|
static ij.measure.ResultsTable |
getFalsePositiveErrorPerLabel(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the false positive error between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getFalsePositiveErrorPerLabel(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the false positive error between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getFalsePositiveErrorPerLabel(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the false positive error between two label images (source and target)
per each individual labeled region.
|
static double |
getJaccardIndex(ij.ImagePlus labelImage1,
ij.ImagePlus labelImage2)
Get the Jaccard index (intersection over union overlap) between
two label images.
|
static double |
getJaccardIndex(ij.process.ImageProcessor labelImage1,
ij.process.ImageProcessor labelImage2)
Get the Jaccard index (intersection over union overlap) between
two label images.
|
static double |
getJaccardIndex(ij.ImageStack labelImage1,
ij.ImageStack labelImage2)
Get the Jaccard index (intersection over union overlap) between
two label images.
|
static ij.measure.ResultsTable |
getJaccardIndexPerLabel(ij.ImagePlus labelImage1,
ij.ImagePlus labelImage2)
Get the Jaccard index per label (intersection over union overlap) between
two label images.
|
static ij.measure.ResultsTable |
getJaccardIndexPerLabel(ij.process.ImageProcessor labelImage1,
ij.process.ImageProcessor labelImage2)
Get the Jaccard index per label (intersection over union overlap) between
two label images.
|
static ij.measure.ResultsTable |
getJaccardIndexPerLabel(ij.ImageStack labelImage1,
ij.ImageStack labelImage2)
Get the Jaccard index per label (intersection over union overlap) between
two label images.
|
static ArrayList<Float> |
getSelectedLabels(ij.ImagePlus labelImage,
ij.gui.Roi roi)
Get list of selected labels in label image.
|
static ij.measure.ResultsTable |
getTargetOverlapPerLabel(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the target overlap between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getTargetOverlapPerLabel(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the target overlap between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getTargetOverlapPerLabel(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the target overlap between two label images (source and target)
per each individual labeled region.
|
static double |
getTotalOverlap(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the total overlap between two label images (source and target).
|
static double |
getTotalOverlap(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the total overlap between two label images (source and target).
|
static double |
getTotalOverlap(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the total overlap between two label images (source and target).
|
static double |
getVolumeSimilarity(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the total volume similarity between two label images (source and target).
|
static double |
getVolumeSimilarity(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the total volume similarity between two label images (source and target).
|
static double |
getVolumeSimilarity(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the total volume similarity between two label images (source and target).
|
static ij.measure.ResultsTable |
getVolumeSimilarityPerLabel(ij.ImagePlus sourceImage,
ij.ImagePlus targetImage)
Get the volume similarity between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getVolumeSimilarityPerLabel(ij.process.ImageProcessor sourceImage,
ij.process.ImageProcessor targetImage)
Get the volume similarity between two label images (source and target)
per each individual labeled region.
|
static ij.measure.ResultsTable |
getVolumeSimilarityPerLabel(ij.ImageStack sourceImage,
ij.ImageStack targetImage)
Get the volume similarity between two label images (source and target)
per each individual labeled region.
|
static boolean |
isLabelImageType(ij.ImagePlus imagePlus)
Checks if the input image may be a label image, and returns false if the
type is not valid for label images.
|
static ij.ImagePlus |
keepLabels(ij.ImagePlus imagePlus,
int[] labels)
Creates a new image containing only the specified labels.
|
static ij.process.ImageProcessor |
keepLabels(ij.process.ImageProcessor image,
int[] labels)
Creates a new image containing only the specified labels.
|
static ij.ImageStack |
keepLabels(ij.ImageStack image,
int[] labels)
Creates a new image containing only the specified labels.
|
static ij.ImagePlus |
keepLargestLabel(ij.ImagePlus imagePlus)
Returns a binary image that contains only the largest label.
|
static ij.process.ImageProcessor |
keepLargestLabel(ij.process.ImageProcessor image)
Returns a binary image that contains only the largest label.
|
static ij.ImageStack |
keepLargestLabel(ij.ImageStack image)
Returns a binary image that contains only the largest label.
|
static ij.process.ImageProcessor |
labelBoundaries(ij.process.ImageProcessor image)
Creates a binary 2D image that contains 255 for pixels that are
boundaries between two labels.
|
static ij.ImageStack |
labelBoundaries(ij.ImageStack image)
Creates a binary 3D image that contains 255 for voxels that are
boundaries between two labels.
|
static ij.ImagePlus |
labelToRgb(ij.ImagePlus imagePlus,
byte[][] lut,
Color bgColor)
Creates a new Color image from a label image, a LUT, and a
color for background.
|
static ij.process.ColorProcessor |
labelToRgb(ij.process.ImageProcessor image,
byte[][] lut,
Color bgColor)
Creates a new Color image from a label planar image, a LUT, and a
color for background.
|
static ij.ImageStack |
labelToRgb(ij.ImageStack image,
byte[][] lut,
Color bgColor)
Creates a new Color image stack from a label image stack, a LUT, and a
color for background.
|
static HashMap<Integer,Integer> |
mapLabelIndices(int[] labels)
Creates an associative array to retrieve the index corresponding to each label.
|
static void |
mergeLabels(ij.ImagePlus labelImage,
ij.gui.Roi roi,
boolean verbose)
Merge labels selected by freehand or point tool.
|
static void |
mergeLabelsWithGap(ij.ImagePlus imagePlus,
float[] labels,
float newLabel,
int conn)
Merge several regions identified by their label, filling the gap between
former regions.
|
static void |
mergeLabelsWithGap(ij.ImagePlus labelImage,
ij.gui.Roi roi,
int conn,
boolean verbose)
Merge labels selected by freehand or point tool.
|
static void |
mergeLabelsWithGap(ij.process.ImageProcessor image,
float[] labels,
float newLabel,
int conn)
Merge several regions identified by their label, filling the gap between
former regions.
|
static void |
mergeLabelsWithGap(ij.ImageStack image,
float[] labels,
float newLabel,
int conn)
Merge several regions identified by their label, filling the gap between
former regions.
|
static int[] |
pixelCount(ij.ImagePlus image,
int[] labels)
Computes the number of pixels (or voxels) composing each regions in the
2D or 3D label image.
|
static int[] |
pixelCount(ij.process.ImageProcessor image,
int[] labels)
Computes the number of pixels composing each particle in the label image.
|
static ij.ImagePlus |
regionComponentsLabeling(ij.ImagePlus imagePlus,
int regionLabel,
int conn,
int bitDepth)
Computes the labels in the binary 2D or 3D image contained in the given
ImagePlus, and computes the maximum label to set up the display range of
the resulting ImagePlus.
|
static ij.process.ImageProcessor |
regionComponentsLabeling(ij.process.ImageProcessor image,
int regionLabel,
int conn,
int bitDepth)
Computes the labels of the connected components in the given planar
binary image.
|
static ij.ImageStack |
regionComponentsLabeling(ij.ImageStack image,
int regionLabel,
int conn,
int bitDepth)
Computes the labels of the connected components in the given 3D binary
image.
|
static void |
remapLabels(ij.ImagePlus imagePlus)
Ensures that the labels in the given label image range from 1 to Lmax.
|
static void |
remapLabels(ij.process.ImageProcessor image)
Ensures that the labels in the given label image range from 1 to Lmax.
|
static void |
remapLabels(ij.ImageStack image)
Ensures that the labels in the given label image range from 1 to Lmax.
|
static void |
removeBorderLabels(ij.ImagePlus imagePlus)
Removes all regions that touch the borders of the image.
|
static void |
removeBorderLabels(ij.process.ImageProcessor image)
Removes all regions that touch the borders of the image.
|
static void |
removeBorderLabels(ij.ImageStack image)
Removes all regions that touch the borders of the image.
|
static void |
removeLabels(ij.ImagePlus labelImage,
ij.gui.Roi roi,
boolean verbose)
Remove labels selected by freehand or point ROIs (in place).
|
static void |
removeLargestLabel(ij.ImagePlus imagePlus)
Removes the regions corresponding to the largest label from a label image.
|
static void |
removeLargestLabel(ij.process.ImageProcessor image)
Removes the regions corresponding to the largest label from a label
image.
|
static void |
removeLargestLabel(ij.ImageStack image)
Removes the regions corresponding to the largest label from a label
image.
|
static void |
replaceLabels(ij.ImagePlus imagePlus,
float[] labels,
float newLabel)
Replace all values specified in label array by the value 0.
|
static void |
replaceLabels(ij.ImagePlus imagePlus,
int[] labels,
int newLabel)
Replace all values specified in label array by a new value.
|
static void |
replaceLabels(ij.process.ImageProcessor image,
float[] labels,
float newLabel)
Replace all values specified in label array by the value 0.
|
static void |
replaceLabels(ij.process.ImageProcessor image,
int[] labels,
int newLabel)
Replace all values specified in label array by a new value.
|
static void |
replaceLabels(ij.ImageStack image,
float[] labels,
float newLabel)
Replace all values specified in label array by the specified value.
|
static void |
replaceLabels(ij.ImageStack image,
int[] labels,
int newLabel)
Replace all values specified in label array by a new value.
|
static ij.ImagePlus |
sizeOpening(ij.ImagePlus labelImage,
int minElementCount)
Applies size opening on a label image: creates a new label image that
contains only particles with at least the specified number of pixels or
voxels.
|
static ij.ImageStack |
volumeOpening(ij.ImageStack labelImage,
int nVoxelMin)
Applies area opening on a 3D label image: creates a new label image that
contains only particle with at least the specified number of voxels.
|
static int[] |
voxelCount(ij.ImageStack image,
int[] labels)
Counts the number of voxels that compose each labeled particle in 3D
image.
|
protected LabelImages()
public static final boolean isLabelImageType(ij.ImagePlus imagePlus)
imagePlus
- the input image to checkpublic static final ij.process.ImageProcessor createLabelImage(int width, int height, int nLabels)
width
- the width of the new label imageheight
- the height of the new label imagenLabels
- expected number of labels in new imagepublic static final ij.ImageStack createLabelStack(int width, int height, int depth, int nLabels)
width
- the width of the new label imageheight
- the height of the new label imagedepth
- the depth (number of slices) of the new label imagenLabels
- expected number of labels in new imagepublic static final ij.process.ByteProcessor createLabelImage(ij.process.ImageProcessor... images)
Creates a new label image from a set of binary images. The label values range between 1 and the number of images.
Example:
ImageProcessor binary1 = new ByteProcessor(10, 10);
binary1.set(2, 2, 255);
binary1.set(3, 5, 255);
ImageProcessor binary2 = new ByteProcessor(10, 10);
binary2.set(4, 4, 255);
binary2.set(3, 5, 255); // overlap of binary images
ImageProcessor binary3 = new ByteProcessor(10, 10);
binary3.set(6, 6, 255);
ImageProcessor labels = LabelImages.createLabelImage(binary1,
binary2, binary3);
int background = labels.get(1, 1); // returns 0
int label1 = labels.get(2, 2); // returns 1
int label2 = labels.get(4, 4); // returns 2
int label3 = labels.get(6, 6); // returns 3
int label1overlap2 = labels.get(3, 5); // returns 2
images
- a collection of binary images (0: background, >0 pixel belongs
to current label)public static final ij.ImageStack labelBoundaries(ij.ImageStack image)
image
- a 3D image containing label regionspublic static final ij.process.ImageProcessor labelBoundaries(ij.process.ImageProcessor image)
image
- a 2D image containing label regionspublic static final ij.process.ImageProcessor binarize(ij.process.ImageProcessor image, int label)
true
only when the corresponding value in the input image equals label
.image
- the input label maplabel
- the label of the region to binarize. Using a value equal to
zero binarizes the background.public static final ij.ImagePlus cropLabel(ij.ImagePlus imagePlus, int label, int border)
imagePlus
- an image containing label of particleslabel
- the label of the particle to selectborder
- the number of pixels to add to each side of the particlepublic static final ij.process.ImageProcessor cropLabel(ij.process.ImageProcessor image, int label, int border)
image
- a, image containing label of particleslabel
- the label of the particle to selectborder
- the number of pixels to add to each side of the particlepublic static final ij.ImageStack cropLabel(ij.ImageStack image, int label, int border)
image
- a 3D image containing label of particleslabel
- the label of the particle to selectborder
- the number of voxels to add to each side of the particlepublic static final ij.ImagePlus sizeOpening(ij.ImagePlus labelImage, int minElementCount)
labelImage
- an image of label regionsminElementCount
- the minimal number of pixels or voxels of regionsareaOpening(ImageProcessor, int)
,
volumeOpening(ImageStack, int)
public static final ij.process.ImageProcessor areaOpening(ij.process.ImageProcessor labelImage, int nPixelMin)
labelImage
- an image of label regionsnPixelMin
- the minimal number of pixels of regionspublic static final ij.ImageStack volumeOpening(ij.ImageStack labelImage, int nVoxelMin)
labelImage
- an image of label regionsnVoxelMin
- the minimal number of voxels of regionspublic static final ij.ImagePlus labelToRgb(ij.ImagePlus imagePlus, byte[][] lut, Color bgColor)
imagePlus
- a 2D or 3D image containing labels and 0 for backgroundlut
- the array of color components for each labelbgColor
- the background colorpublic static final ij.process.ColorProcessor labelToRgb(ij.process.ImageProcessor image, byte[][] lut, Color bgColor)
image
- an ImageProcessor with label values and 0 for backgroundlut
- the array of color components for each labelbgColor
- the background colorpublic static final ij.ImageStack labelToRgb(ij.ImageStack image, byte[][] lut, Color bgColor)
image
- an ImageStack with label values and 0 for backgroundlut
- the array of color components for each labelbgColor
- the background colorpublic static final void removeBorderLabels(ij.ImagePlus imagePlus)
imagePlus
- a label imagepublic static final void removeBorderLabels(ij.process.ImageProcessor image)
image
- a label imagepublic static final void removeBorderLabels(ij.ImageStack image)
image
- a label imagepublic static final ij.ImagePlus keepLargestLabel(ij.ImagePlus imagePlus)
imagePlus
- an instance of ImagePlus containing a label imagepublic static final ij.process.ImageProcessor keepLargestLabel(ij.process.ImageProcessor image)
image
- a label imageRuntimeException
- if the image is emptypublic static final ij.ImageStack keepLargestLabel(ij.ImageStack image)
image
- a label imageRuntimeException
- if the image is emptypublic static final void removeLargestLabel(ij.ImagePlus imagePlus)
imagePlus
- a label imagepublic static final void removeLargestLabel(ij.process.ImageProcessor image)
image
- a label imagepublic static final void removeLargestLabel(ij.ImageStack image)
image
- a 3D label imagepublic static final int[] pixelCount(ij.ImagePlus image, int[] labels)
image
- a label image (2D or 3D)labels
- the array of label indices to processpublic static final int[] pixelCount(ij.process.ImageProcessor image, int[] labels)
image
- a label imagelabels
- the array of label indices to processGeometricMeasures2D.area(ij.process.ImageProcessor,
int[], double[])
public static final int[] voxelCount(ij.ImageStack image, int[] labels)
image
- a label imagelabels
- the array of label indices to processGeometricMeasures3D.volume(ij.ImageStack, int[], double[])
public static final int findLargestLabel(ij.ImagePlus imagePlus)
imagePlus
- input imagepublic static final int[] findAllLabels(ij.ImagePlus image)
image
- an instance of ImagePlus containing a label imagepublic static final int[] findAllLabels(ij.ImageStack image)
image
- a 3D label imagepublic static final int[] findAllLabels(ij.process.ImageProcessor image)
image
- a label imagepublic static final void replaceLabels(ij.ImagePlus imagePlus, int[] labels, int newLabel)
imagePlus
- an ImagePlus containing a 3D label imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void replaceLabels(ij.ImagePlus imagePlus, float[] labels, float newLabel)
imagePlus
- an ImagePlus containing a 3D label imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void replaceLabels(ij.process.ImageProcessor image, int[] labels, int newLabel)
image
- a label planar imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void replaceLabels(ij.process.ImageProcessor image, float[] labels, float newLabel)
image
- a label planar imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void replaceLabels(ij.ImageStack image, int[] labels, int newLabel)
image
- a label 3D imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void replaceLabels(ij.ImageStack image, float[] labels, float newLabel)
image
- a 3D label imagelabels
- the list of labels to replacenewLabel
- the new value for labelspublic static final void remapLabels(ij.ImagePlus imagePlus)
imagePlus
- the instance of ImagePlus containing the label imagepublic static final void remapLabels(ij.process.ImageProcessor image)
image
- the label imagepublic static final void remapLabels(ij.ImageStack image)
image
- the 3D label imagepublic static final ij.ImagePlus keepLabels(ij.ImagePlus imagePlus, int[] labels)
imagePlus
- an ImagePlus containing a planar label imagelabels
- the list of values to keeppublic static final ij.process.ImageProcessor keepLabels(ij.process.ImageProcessor image, int[] labels)
image
- a planar label imagelabels
- the list of values to keeppublic static final ij.ImageStack keepLabels(ij.ImageStack image, int[] labels)
image
- a 3D label imagelabels
- the list of values to keeppublic static final ij.ImagePlus applyLut(ij.ImagePlus labelImage, double[] values)
labelImage
- a label image (2D or 3D)values
- a set of values associated to each unique labelpublic static final ij.process.FloatProcessor applyLut(ij.process.ImageProcessor labelImage, double[] values)
labelImage
- a label imagevalues
- a set of values associated to each unique labelpublic static final ij.ImageStack applyLut(ij.ImageStack labelImage, double[] values)
labelImage
- a 3D label imagevalues
- a set of values associated to each unique labelpublic static final HashMap<Integer,Integer> mapLabelIndices(int[] labels)
The resulting map verifies the relation:
int[] labels = ...
Map<Integer,Integer> labelIndices = LabelImages.mapLabelIndices(labels);
int index = ...
assert(index == labelIndices.get(labels[index]));
labels
- an array of labelspublic static final ij.ImagePlus regionComponentsLabeling(ij.ImagePlus imagePlus, int regionLabel, int conn, int bitDepth)
imagePlus
- contains the 3D binary image stackregionLabel
- the label of the region to process, that can be the background
(value 0)conn
- the connectivity, either 4 or 8 for planar images, or 6 or 26
for 3D imagesbitDepth
- the number of bits used to create the result image (8, 16 or
32)RuntimeException
- if the number of labels reaches the maximum number that can
be represented with this bitDepthFloodFillRegionComponentsLabeling
,
FloodFillRegionComponentsLabeling3D
,
FloodFill
public static final ij.process.ImageProcessor regionComponentsLabeling(ij.process.ImageProcessor image, int regionLabel, int conn, int bitDepth)
image
- contains the binary image (any type is accepted)regionLabel
- the label of the region to process, that can be the background
(value 0)conn
- the connectivity, either 4 or 8bitDepth
- the number of bits used to create the result image (8, 16 or
32)RuntimeException
- if the number of labels reaches the maximum number that can
be represented with this bitDepthFloodFillRegionComponentsLabeling
,
ConnectedComponentsLabeling
public static final ij.ImageStack regionComponentsLabeling(ij.ImageStack image, int regionLabel, int conn, int bitDepth)
image
- contains the 3D binary image (any type is accepted)regionLabel
- the label of the region to process, that can be the background
(value 0)conn
- the connectivity, either 6 or 26bitDepth
- the number of bits used to create the result stack (8, 16 or
32)RuntimeException
- if the number of labels reaches the maximum number that can
be represented with this bitDepthFloodFillRegionComponentsLabeling3D
,
ConnectedComponentsLabeling3D
public static final void mergeLabels(ij.ImagePlus labelImage, ij.gui.Roi roi, boolean verbose)
labelImage
- label image to modifyroi
- selection indicating the labels to mergeverbose
- option to write in the log window the labels mergedpublic static final void mergeLabelsWithGap(ij.ImagePlus labelImage, ij.gui.Roi roi, int conn, boolean verbose)
labelImage
- label image to modifyroi
- selection indicating the labels to mergeconn
- the connectivity to check for neighbors of background labelsverbose
- option to write in the log window the labels mergedpublic static final void mergeLabelsWithGap(ij.ImagePlus imagePlus, float[] labels, float newLabel, int conn)
imagePlus
- an ImagePlus containing a 3D label imagelabels
- the list of labels to replacenewLabel
- the new value for labelsconn
- the connectivity to check neighbors of background pixelspublic static final void mergeLabelsWithGap(ij.process.ImageProcessor image, float[] labels, float newLabel, int conn)
image
- a label planar imagelabels
- the list of labels to replacenewLabel
- the new value for labelsconn
- the connectivity to check neighbors of background pixelspublic static final void mergeLabelsWithGap(ij.ImageStack image, float[] labels, float newLabel, int conn)
image
- a 3D label imagelabels
- the list of labels to replacenewLabel
- the new value for labelsconn
- the connectivity to check neighbors of background pixelspublic static final void removeLabels(ij.ImagePlus labelImage, ij.gui.Roi roi, boolean verbose)
labelImage
- input label imageroi
- FreehandRoi or PointRoi with selected labelsverbose
- flag to print deleted labels in log windowpublic static final ij.process.ImageProcessor distanceMap(ij.process.ImageProcessor image)
image
- the input label imagepublic static final ij.process.ImageProcessor distanceMap(ij.process.ImageProcessor image, ChamferMask2D mask, boolean floatingPoint, boolean normalize)
Computes the distance map for each region within a label map, by specifying the chamfer mask and the normalization.
Distance is computed for each foreground (white) pixel, as the chamfer
distance to the nearest background (black) pixel. Result is given in a
new instance of FloatProcessor
or
ShortProcessort
, depending on the floatingPoint
flag.
image
- the input binary or label imagemask
- the chamfer mask used to propagate distancesfloatingPoint
- indicates if the computation should be performed using
floating point computationnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.process.ImageProcessor distanceMap(ij.process.ImageProcessor image, short[] weights, boolean normalize)
image
- the input image of labelsweights
- an array of chamfer weights, with at least three valuesnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.process.ImageProcessor distanceMap(ij.process.ImageProcessor image, float[] weights, boolean normalize)
image
- the input 3D image of labelsweights
- an array of chamfer weights, with at least three valuesnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.ImageStack distanceMap(ij.ImageStack image)
image
- the input 3D label imagepublic static final ij.ImageStack distanceMap(ij.ImageStack image, ChamferMask3D mask, boolean floatingPoint, boolean normalize)
Computes the 3D distance map from an image of labels, by specifying the chamfer mask and the normalization.
Distance is computed for each foreground (white) pixel, as the chamfer distance to the nearest background (black) pixel. Result is given in a new instance of FloatProcessor.
image
- the input 3D binary or label imagemask
- the chamfer mask used to propagate distancesfloatingPoint
- indicates if the computation should be performed using
floating point computationnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.ImageStack distanceMap(ij.ImageStack image, short[] weights, boolean normalize)
image
- the input 3D image of labelsweights
- an array of chamfer weights, with at least three valuesnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.ImageStack distanceMap(ij.ImageStack image, float[] weights, boolean normalize)
image
- the input 3D image of labelsweights
- an array of chamfer weights, with at least three valuesnormalize
- indicates whether the resulting distance map should be
normalized (divide distances by the first chamfer weight)public static final ij.ImagePlus dilateLabels(ij.ImagePlus imagePlus, double distMax)
imagePlus
- the image of regions to processdistMax
- the maximum distance used for dilationpublic static final ij.process.ImageProcessor dilateLabels(ij.process.ImageProcessor labelMap, double radius)
labelMap
- the image of regions to processradius
- the radius of dilation of labels over the backgroundpublic static final ij.ImageStack dilateLabels(ij.ImageStack labelMap, double radius)
labelMap
- the image of regions to processradius
- the radius of dilation of labels over the backgroundpublic static final ArrayList<Float> getSelectedLabels(ij.ImagePlus labelImage, ij.gui.Roi roi)
labelImage
- label imageroi
- FreehandRoi or PointRoi with selected labelspublic static final double getTotalOverlap(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
Total Overlap (for all regions) $TO = \frac{ \sum_r{|S_r \cap T_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getTargetOverlapPerLabel(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
Target Overlap (for individual label regions r) $TO_r = \frac{ |S_r \cap T_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getTotalOverlap(ij.ImageStack sourceImage, ij.ImageStack targetImage)
Total Overlap (for all regions) $TO = \frac{ \sum_r{|S_r \cap T_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getTotalOverlap(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
Total Overlap (for all regions) $TO = \frac{ \sum_r{|S_r \cap T_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getTargetOverlapPerLabel(ij.ImageStack sourceImage, ij.ImageStack targetImage)
Target Overlap (for individual label regions r) $TO_r = \frac{ |S_r \cap T_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getTargetOverlapPerLabel(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
Target Overlap (for individual label regions r) $TO_r = \frac{ |S_r \cap T_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getJaccardIndex(ij.process.ImageProcessor labelImage1, ij.process.ImageProcessor labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getJaccardIndexPerLabel(ij.process.ImageProcessor labelImage1, ij.process.ImageProcessor labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getJaccardIndex(ij.ImageStack labelImage1, ij.ImageStack labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getJaccardIndexPerLabel(ij.ImageStack labelImage1, ij.ImageStack labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getJaccardIndex(ij.ImagePlus labelImage1, ij.ImagePlus labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getJaccardIndexPerLabel(ij.ImagePlus labelImage1, ij.ImagePlus labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getDiceCoefficient(ij.process.ImageProcessor labelImage1, ij.process.ImageProcessor labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getDiceCoefficientPerLabel(ij.process.ImageProcessor labelImage1, ij.process.ImageProcessor labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getDiceCoefficient(ij.ImageStack labelImage1, ij.ImageStack labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getDiceCoefficientPerLabel(ij.ImageStack labelImage1, ij.ImageStack labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getDiceCoefficient(ij.ImagePlus labelImage1, ij.ImagePlus labelImage2)
labelImage1
- first label imagelabelImage2
- second label imagepublic static final ij.measure.ResultsTable getDiceCoefficientPerLabel(ij.ImagePlus labelImage1, ij.ImagePlus labelImage2)
labelImage1
- reference label imagelabelImage2
- label image to compare withpublic static final double getVolumeSimilarity(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
Volume Similarity (for all regions) $VS = 2\frac{ \sum_r{|S_r| - |T_r|} }{ \sum_r{|S_r| + |T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getVolumeSimilarityPerLabel(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
Volume Similarity (for each label region r) $VS_r = 2\frac{ |S_r| - |T_r| }{ |S_r| + |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getVolumeSimilarity(ij.ImageStack sourceImage, ij.ImageStack targetImage)
Volume Similarity (for all regions) $VS = 2\frac{ \sum_r{|S_r| - |T_r|} }{ \sum_r{|S_r| + |T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getVolumeSimilarityPerLabel(ij.ImageStack sourceImage, ij.ImageStack targetImage)
Volume Similarity (for each label region r) $VS_r = 2\frac{ |S_r| - |T_r| }{ |S_r| + |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getVolumeSimilarity(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
Volume Similarity (for all regions) $VS = 2\frac{ \sum_r{|S_r| - |T_r|} }{ \sum_r{|S_r| + |T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getVolumeSimilarityPerLabel(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
Volume Similarity (for each label region r) $VS_r = 2\frac{ |S_r| - |T_r| }{ |S_r| + |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalseNegativeError(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
False Negative Error (for all regions) $FN = \frac{ \sum_r{|T_r \setminus S_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalseNegativeErrorPerLabel(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
False Negative Error (for each individual labeled region r) $FN_r = \frac{ |T_r \setminus S_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalseNegativeError(ij.ImageStack sourceImage, ij.ImageStack targetImage)
False Negative Error (for all regions) $FN = \frac{ \sum_r{|T_r \setminus S_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalseNegativeErrorPerLabel(ij.ImageStack sourceImage, ij.ImageStack targetImage)
False Negative Error (for each individual labeled region r) $FN_r = \frac{ |T_r \setminus S_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalseNegativeError(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
False Negative Error (for all regions) $FN = \frac{ \sum_r{|T_r \setminus S_r|} }{ \sum_r{|T_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalseNegativeErrorPerLabel(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
False Negative Error (for each individual labeled region r) $FN_r = \frac{ |T_r \setminus S_r| }{ |T_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalsePositiveError(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
False Positive Error (for all regions) $FP = \frac{ \sum_r{|S_r \setminus T_r|} }{ \sum_r{|S_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalsePositiveErrorPerLabel(ij.process.ImageProcessor sourceImage, ij.process.ImageProcessor targetImage)
False Positive Error (for each individual labeled region r) $FN_r = \frac{ |S_r \setminus T_r| }{ |S_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalsePositiveError(ij.ImageStack sourceImage, ij.ImageStack targetImage)
False Positive Error (for all regions) $FP = \frac{ \sum_r{|S_r \setminus T_r|} }{ \sum_r{|S_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalsePositiveErrorPerLabel(ij.ImageStack sourceImage, ij.ImageStack targetImage)
False Positive Error (for each individual labeled region r) $FN_r = \frac{ |S_r \setminus T_r| }{ |S_r| }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final double getFalsePositiveError(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
False Positive Error (for all regions) $FP = \frac{ \sum_r{|S_r \setminus T_r|} }{ \sum_r{|S_r|} }$.
sourceImage
- source label imagetargetImage
- target label imagepublic static final ij.measure.ResultsTable getFalsePositiveErrorPerLabel(ij.ImagePlus sourceImage, ij.ImagePlus targetImage)
False Positive Error (for each individual labeled region r) $FN_r = \frac{ |S_r \setminus T_r| }{ |S_r| }$.
sourceImage
- source label imagetargetImage
- target label image@Deprecated public static final Point[] findPositionOfMaxValues(ij.process.ImageProcessor valueImage, ij.process.ImageProcessor labelImage, int[] labels)
labelImage
and with maximal value in intensity
image valueImage
.valueImage
- the intensity image containing values to comparelabelImage
- the intensity image containing label of each pixellabels
- the list of labels in the label image@Deprecated public static final Point[] findPositionOfMinValues(ij.process.ImageProcessor valueImage, ij.process.ImageProcessor labelImage, int[] labels)
labelImage
and with minimal value in intensity
image valueImage
.valueImage
- the intensity image containing values to comparelabelImage
- the intensity image containing label of each pixellabels
- the list of labels in the label imageCopyright © 2014–2023 INRA-IJPB Modeling and Digital Imaging lab. All rights reserved.