inra.ijpb.measure

Class GeometricMeasures3D

• java.lang.Object
• inra.ijpb.measure.GeometricMeasures3D

• ```public class GeometricMeasures3D
extends java.lang.Object```
Provides a set of static methods to compute geometric measures in 3D binary or label images. Ideally, each parameter should provide two methods to measure it:
• a method with two (or more) input parameters: the label image and the resolution, and which returns a ResultsTable
• a method with three (or more) input parameters: the label image, the list of labels to consider, and the resolution, and which returns an array of double, with as many elements as the number of labels

Example of code:

``````ImageStack labelImage = ...
int[] labels = LabelImages.findAllLabels(image);
double[] resol = new double[]{1, 1, 1};
double[][] ellipsoids = GeometricMeasures3D.inertiaEllipsoid(labelImage,
labels, resol);
double[][] elongations = GeometricMeasures3D.computeEllipsoidElongations(ellipsoids);
``````
Author:
David Legland
• Method Summary

Methods
Modifier and Type Method and Description
`static ij.measure.ResultsTable` `boundingBox(ij.ImageStack labelImage)`
Computes bounding box of each label in input stack and returns the result as a ResultsTable.
`static double[][]` ```boundingBox(ij.ImageStack labelImage, int[] labels)```
Computes bounding box of each label in input stack and returns the result as an array of double for each label.
`static double[][]` ```centroids(ij.ImageStack labelImage, int[] labels)```
Computes centroid of each label in input stack and returns the result as an array of double for each label.
`static double[][]` `computeEllipsoidElongations(double[][] ellipsoids)`
Computes the three elongation factors for an array of ellipsoids.
`static double[]` ```computeSphericity(double[] volumes, double[] surfaces)```
Helper function that computes the sphericity index of 3D particles, based on the value of volume and surface area.
`static double[]` ```eulerNumber(ij.ImageStack image, int[] labels, int conn)```
Computes Euler number for each label given in the "labels" argument, using the specified connectivity.
`static ij.measure.ResultsTable` `inertiaEllipsoid(ij.ImageStack image)`
Computes inertia ellipsoid of each 3D region in input 3D label image.
`static ij.measure.ResultsTable` ```inertiaEllipsoid(ij.ImageStack image, double[] resol)```
Computes inertia ellipsoid of each 3D region in input 3D label image.
`static double[][]` ```inertiaEllipsoid(ij.ImageStack image, int[] labels, double[] resol)```
Computes inertia ellipsoid from input 3D label image for each specified region label.
`static ij.measure.ResultsTable` ```maximumInscribedSphere(ij.ImageStack labelImage, double[] resol)```
Radius of maximum inscribed sphere of each particle within a label image.
`static double[][]` ```maximumInscribedSphere(ij.ImageStack labelImage, int[] labels, double[] resol)```
Radius of maximum inscribed sphere of each particle within a label image.
`static ij.measure.ResultsTable` ```surfaceArea(ij.ImageStack labelImage, double[] resol, int nDirs)```
Computes the surface area of each label in the 3D image, using the specified resolution, and the given number of directions.
`static double[]` ```surfaceAreaCrofton(ij.ImageStack image, int[] labels, double[] resol, int nDirs)```
Computes surface area for each label given in the "labels" argument.
`static double` ```surfaceAreaCrofton(ij.ImageStack image, int label, double[] resol, int nDirs)```
Computes surface area for a single label in the image, using discretization of the Crofton formula.
`static double` ```surfaceAreaCroftonD3(ij.ImageStack image, double[] resol)```
Computes surface area of a binary image using 3 directions.
`static ij.measure.ResultsTable` ```volume(ij.ImageStack labelImage, double[] resol)```
Measures the volume of each particle in a 3D label image.
`static double[]` ```volume(ij.ImageStack labelImage, int[] labels, double[] resol)```
Measures the volume of each particle in the 3D label image.
• Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• Method Detail

• boundingBox

`public static final ij.measure.ResultsTable boundingBox(ij.ImageStack labelImage)`
Computes bounding box of each label in input stack and returns the result as a ResultsTable.
Parameters:
`labelImage` - a 3D image containing label of particles or regions
Returns:
a new ResultsTable containing for each label, the extent of the corresponding region
• boundingBox

```public static final double[][] boundingBox(ij.ImageStack labelImage,
int[] labels)```
Computes bounding box of each label in input stack and returns the result as an array of double for each label.
Parameters:
`labelImage` - a 3D image containing label of particles or regions
`labels` - the set of labels present in image
Returns:
a new array of doubles containing for each label, the extent of the corresponding region
• volume

```public static final ij.measure.ResultsTable volume(ij.ImageStack labelImage,
double[] resol)```
Measures the volume of each particle in a 3D label image.
Parameters:
`labelImage` - image containing the label of each particle
`resol` - image resolution, as a double array with 3 elements
Returns:
the volume of each particle in the image
• volume

```public static final double[] volume(ij.ImageStack labelImage,
int[] labels,
double[] resol)```
Measures the volume of each particle in the 3D label image.
Parameters:
`labelImage` - image containing the label of each particle
`labels` - the set of labels for which volume has to be computed
`resol` - image resolution, as a double array with 3 elements
Returns:
the volume of each particle in the image
• computeSphericity

```public static final double[] computeSphericity(double[] volumes,
double[] surfaces)```
Helper function that computes the sphericity index of 3D particles, based on the value of volume and surface area. The sphericity is computed using the following formula: ``` sphericity = 36 * PI * V^2 / S^3 ``` A perfect ball would have a sphericity index close to 1, a very complex particle will present a lower sphericity index.
Parameters:
`volumes` - the volume of each particle
`surfaces` - the surface area of each particle
Returns:
the sphericity index of each particle
See Also:
`surfaceArea(ImageStack, double[], int)`, `volume(ImageStack, int[], double[])`
• surfaceArea

```public static final ij.measure.ResultsTable surfaceArea(ij.ImageStack labelImage,
double[] resol,
int nDirs)```
Computes the surface area of each label in the 3D image, using the specified resolution, and the given number of directions. Current algorithms pre-computes a LUT, then iterate on 2-by-2-by-2 configurations of voxels, and identifies the labels whose surface area measure need to be updated. For 3 directions, the surfaceAreaD3 function is an alternative that does not uses LUT.
Parameters:
`labelImage` - image containing the label of each particle
`resol` - image resolution, as a double array with 3 elements
`nDirs` - the number of directions to consider, either 3 or 13
Returns:
the surface area of each particle in the image
• surfaceAreaCrofton

```public static final double[] surfaceAreaCrofton(ij.ImageStack image,
int[] labels,
double[] resol,
int nDirs)```
Computes surface area for each label given in the "labels" argument.
Parameters:
`image` - image containing the label of each particle
`labels` - the set of labels in the image
`resol` - image resolution, as a double array with 3 elements
`nDirs` - the number of directions to consider, either 3 or 13
Returns:
the surface area of each particle in the image
• surfaceAreaCrofton

```public static final double surfaceAreaCrofton(ij.ImageStack image,
int label,
double[] resol,
int nDirs)```
Computes surface area for a single label in the image, using discretization of the Crofton formula. This can be useful for binary images by using label 255.
Parameters:
`image` - the input 3D label image (with labels having integer values)
`label` - the value of the label to measure
`resol` - the resolution of the image, in each direction
`nDirs` - the number of directions to consider for computing surface (3 or 13)
Returns:
the surface area measured for the given label
• surfaceAreaCroftonD3

```public static final double surfaceAreaCroftonD3(ij.ImageStack image,
double[] resol)```
Computes surface area of a binary image using 3 directions.
Parameters:
`image` - the input 3D label image (with labels having integer values)
`resol` - the resolution of the image, in each direction
Returns:
the surface area measured for the binary image
• eulerNumber

```public static final double[] eulerNumber(ij.ImageStack image,
int[] labels,
int conn)```
Computes Euler number for each label given in the "labels" argument, using the specified connectivity.
Parameters:
`image` - the input 3D label image (with labels having integer values)
`labels` - the set of unique labels in image
`conn` - the connectivity to use (either 6 or 26)
Returns:
the Euler-Poincare characteristic of each region
• centroids

```public static final double[][] centroids(ij.ImageStack labelImage,
int[] labels)```
Computes centroid of each label in input stack and returns the result as an array of double for each label.
Parameters:
`labelImage` - an instance of ImageStack containing region labels
`labels` - the set of indices contained in the image
Returns:
the centroid of each region, as an array of double[3]
• inertiaEllipsoid

`public static final ij.measure.ResultsTable inertiaEllipsoid(ij.ImageStack image)`
Computes inertia ellipsoid of each 3D region in input 3D label image.
Parameters:
`image` - an instance of ImageStack containing region labels
Returns:
the parameters of the inertia ellipsoid for each region
Throws:
`java.lang.RuntimeException` - if jama package is not found.
• inertiaEllipsoid

```public static final ij.measure.ResultsTable inertiaEllipsoid(ij.ImageStack image,
double[] resol)```

Computes inertia ellipsoid of each 3D region in input 3D label image.

The result is given as a ResultsTable with as many rows as the number of labels, and 9 columns. Columns correspond to the centroid coordinates (3 values), the radius of the ellipsoid (3 values), and the orientation, given as azimut, elevation, and roll angles, in degrees (3 values).

Parameters:
`image` - an instance of ImageStack containing region labels
`resol` - the resolution of the image, in each direction
Returns:
the parameters of the inertia ellipsoid for each region
Throws:
`java.lang.RuntimeException` - if jama package is not found.
• inertiaEllipsoid

```public static final double[][] inertiaEllipsoid(ij.ImageStack image,
int[] labels,
double[] resol)```

Computes inertia ellipsoid from input 3D label image for each specified region label.

The result is given as an array of double with as many rows as the number of labels, and 9 columns. Columns correspond to the centroid coordinates (3 values), the radius of the ellipsoid (3 values), and the orientation, given as azimut, elevation, and roll angles, in degrees (3 values).

``````
ImageStack labelImage = ...
int[] labels = LabelImages.findAllLabels(image);
double[] resol = new double[]{1, 1, 1};
double[][] ellipsoids = GeometricMeasures3D.inertiaEllipsoid(labelImage,
labels, resol);
double[][] elongations = GeometricMeasures3D.computeEllipsoidElongations(ellipsoids);
``````
Parameters:
`image` - input image containing label of each particle
`labels` - the list of labels for which we want to compute inertia ellipsoid
`resol` - the spatial resolution, as an array of length 3.
Returns:
an array with as many rows as the number of labels, and 9 columns
Throws:
`java.lang.RuntimeException` - if jama package is not found.
• computeEllipsoidElongations

`public static final double[][] computeEllipsoidElongations(double[][] ellipsoids)`
Computes the three elongation factors for an array of ellipsoids.
``````
ImageStack labelImage = ...
int[] labels = LabelImages.findAllLabels(image);
double[] resol = new double[]{1, 1, 1};
double[][] ellipsoids = GeometricMeasures3D.inertiaEllipsoid(labelImage,
labels, resol);
double[][] elongations = GeometricMeasures3D.computeEllipsoidElongations(ellipsoids);
``````
Parameters:
`ellipsoids` - an array of ellipsoids, with radius data given in columns 3, 4, and 5
Returns:
an array of elongation factors. When radii are ordered such that R1 > R2 > R3, the three elongation factors are defined by ratio of R1 by R2, ratio of R1 by R3, and ratio of R2 by R3.
See Also:
`inertiaEllipsoid(ImageStack, double[])`, `inertiaEllipsoid(ImageStack, int[], double[])`
• maximumInscribedSphere

```public static final ij.measure.ResultsTable maximumInscribedSphere(ij.ImageStack labelImage,
double[] resol)```
Radius of maximum inscribed sphere of each particle within a label image.
Parameters:
`labelImage` - input image containing label of each particle
`resol` - the spatial resolution, as an array of length 3.
Returns:
a ResultsTable with as many rows as the number of labels, and 4 columns (xi, yi, zi, radius)
• maximumInscribedSphere

```public static final double[][] maximumInscribedSphere(ij.ImageStack labelImage,
int[] labels,
double[] resol)```
Radius of maximum inscribed sphere of each particle within a label image.
Parameters:
`labelImage` - input image containing label of each particle
`labels` - the list of labels for which we want to compute inertia ellipsoid
`resol` - the spatial resolution, as an array of length 3.
Returns:
an array with as many rows as the number of labels, and 4 columns (xi, yi, zi, radius)