# Changes

## MorphoLibJ

, 01:46, 4 September 2019
Update latest release info
| name = MorphoLibJ
| software = IJPB-plugins
| update site = IJPB-plugins
| author = [https://github.com/dlegland David Legland], {{Person|Iarganda}}
| maintainer = [https://github.com/dlegland David Legland], {{Person|Iarganda}}
| source = {{GitHub|org=ijpb|repo=MorphoLibJ}}
| released = July 3<sup>rd</sup>, 2014
| status = stable, active
| category = [[:Category:Analysis|Analysis]], [[:Category:Filtering|Filtering]], [[:Category:Segmentation|Segmentation]], [[:Category:Mathematical_morphology|Mathematical morphology]]
== Measurements ==
[[MorphoLibJ]] contains several tools for quantifying the size, the shape, or the spatial organization, from '''binary or label''' 2D and 3D images. The aim is to facilitate the management of label images, contrary to the built-in “Analyze Particles...” function that operates directly on a grayscale image.
=== Particle Region analysis ===This section describes the methods implemented in MorphoLibJ for describing individual particlesregions, represented as label images (one label for each particleregion). We first define and describe the implemented features, then we present the plugins that integrate them.
==== Intrinsic volumes ====
[[Image:MorphoLibJ-Euler-number.png|thumb|400px|Illustration of Euler Number definition. Left: three particles with Euler numbers equal to 1, 0 and -1, respectively. Right: example of a 3D particle with an Euler number equal to -1, corresponding to the subtraction of 1 connected components minus two handles.]]The intrinsic volumes are a set of features with interesting mathematical properties that are commonly used for describing individual particles as well as binary microstructrues. In the planar case, they correspond to the area, the perimeter and the Euler number. The Euler number is a topological characteristic that equals the number of connected components minus the number of holes.
* '''x2, y2''': coordinates of another geodesic extremity of the particle.
===== Particle Region Analysis 3D =====The plugin calculating these measurements is found under {{bc | Plugins | MorphoLibJ | Analyze | Particle Region Analysis 3D}}. The results are provided in an ImageJ Results table, whose name contains the name of the original image.
* '''Label''': the label of the particle measured on the current line (it can be different from the row number if some labels do no exist in original image).
* '''Inertia ellipse / ellipsoid''': returns the centroid (center of gravity) as well as the size and the orientation of the inertia ellipse or ellipsoid of each particle. Radii are sorted in decreasing order. Angles are given in degrees, and correspond to the azimut ("yaw"), the elevation ("pitch"), and the roll around the main axis.
==== Intensity measurements ====
Other measurements are provided for pairs of grayscale and label 2D or 3D images ({{bc | Plugins | MorphoLibJ | Analyze | Intensity Measurements 2D/3D}}). The label image can correspond to a segmented particle, or to a more generic region of interest.
The plugin calculates the '''mean''', '''standard deviation''', '''maximum''', '''minimum''', '''median''', '''mode''', '''skewness''' and '''kurtosis''' of the intensity value distribution of each labeled region in the grayscale image. The results are displayed as well in an ImageJ ''ResultsTable''.

=== Label Overlap Measures ===
Given two label images, there are different measures that allow us to evaluate the overlap
agreement (or error) between the labels. Following Tustison & Gee (2009)<ref name="Tustison2009>{{ cite journal
| title = Introducing Dice, Jaccard, and other label overlap measures to ITK
| author = Tustison, NJ and Gee, JC
| journal = The Insight Journal
| pages = 1-4
| issue = July-December
| year = 2009
| doi = 10.1007/BF01189221
}}</ref>, and given a
source image $S$ and a target image $T$, this plugin (under {{bc | Plugins | MorphoLibJ | Analyze | Label Overlap Measures}}) provides the following overlap measurements in two different result tables (one with the total values for all labels and one with values for individual labels):
* Target Overlap for each individual labeled region $r$:
:$TO_{r}=\frac{|S_{r}\cap T_{r}|}{|T_{r}|}$
* Total Overlap (for all regions):
:$TO=\frac{\sum_{r}{|S_{r}\cap T_{r}|}}{\sum_{r}{|T_{r}|}}$
* [https://en.wikipedia.org/wiki/Jaccard_index Jaccard Index] or Union Overlap for each individual labeled region $r$:
:$UO_{r}=\frac{|S_{r}\cap T_{r}|}{|S_{r}\cup T_{r}|}$
* [https://en.wikipedia.org/wiki/Jaccard_index Jaccard Index] or Union Overlap for all regions:
:$UO=\frac{\sum_{r}|S_{r}\cap T_{r}|}{\sum_{r}|S_{r}\cup T_{r}|}$
* [https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient Dice Coefficient] or Mean Overlap for each individual labeled region $r$:
:$MO_{r}=2\frac{|S_{r}\cap T_{r}|}{|S_{r}|+|T_{r}|}$
* [https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient Dice Coefficient] or Mean Overlap for all regions:
:$MO=2\frac{\sum_{r}|S_{r}\cap T_{r}|}{\sum_{r}\left(|S_{r}|+|T_{r}|\right)}$
* Volume Similarity for each individual labeled region $r$:
:$VS_{r}=2\frac{|S_{r}|-|T_{r}|}{|S_{r}|+|T_{r}|}$
* Volume Similarity for all regions:
:$VS=2\frac{\sum_{r}\left(|S_{r}|-|T_{r}|\right)}{\sum_{r}\left(|S_{r}|+|T_{r}|\right)}$
* False Negative Error for each individual labeled region $r$:
:$FN_{r}=\frac{|T_{r}\setminus S_{r}|}{|T_{r}|}$
* False Negative Error for all regions:
:$FN=\frac{\sum_{r}|T_{r}\setminus S_{r}|}{\sum_{r}|T_{r}|}$
* False Positive Error for each individual labeled region $r$:
:$FP_{r}=\frac{|S_{r}\setminus T_{r}|}{|S_{r}|}$
* False Positive Error for all regions:
:$FP=\frac{\sum_{r}|S{}_{r}\setminus T{}_{r}|}{\sum_{r}|S_{r}|}$
=== Spatial organization ===
<source lang="java">
// #@ImagePlus (label="Input image",description="Image to segment") imp// #@ Integer(label="Gradient radius",description="Radius of the morphological gradient",value=2) radius#@ Integer(label="Tolerance",description="Local extrema dynamic",value=3) tolerance#@ String(label="Connectivity",description="Local connectivity", choices={"6","26"}) strConn#@ Boolean(label="Calculate dams",description="Flag to use dams in watershed",value=true) dams#@OUTPUT ImagePlus resultImage
// ImageJ imports
import ij.IJ;
import inra.ijpb.morphology.Strel3D;
import inra.ijpb.watershed.Watershed;
import inra.ijpb.data.image.Images3D; // convert connectivity string to intconn = Integer.parseInt( strConn ); image = null;if( radius != 0 ){ // create structuring element (cube of radius 1'radius') strel = Strel3D.Shape.CUBE.fromRadius( 1 radius ); // apply morphological gradient to input image image = Morphology.gradient( imp.getImageStack(), strel ); }else image = imp.getImageStack();// find regional minima on gradient image with dynamic value of 30 'tolerance' and 6'conn'-connectivityregionalMinima = MinimaAndMaxima3D.extendedMinima( image, 30tolerance, 6 conn );
// impose minima on gradient image
imposedMinima = MinimaAndMaxima3D.imposeMinima( image, regionalMinima, 6 conn );
// label minima using connected components (32-bit output)
labeledMinima = BinaryImages.componentsLabeling( regionalMinima, 6conn, 32 );
// apply marker-based watershed using the labeled minima on the minima-imposed
// gradient image (the "true" last value indicates the use of dams in the output)resultStack = Watershed.computeWatershed( imposedMinima, labeledMinima, 6conn, true dams );
// create image with watershed result
resultImage = new ImagePlus( "watershed", resultStack );
// assign right calibration
resultImage.setCalibration( imp.getCalibration() );
// optimize display range
Images3D.optimizeDisplayRange( resultImage );
// set same slice as input
resultImage.setSlice( imp.getCurrentSlice() );
</source>
<source lang="java">
// #@ImagePlus imp
import inra.ijpb.label.LabelImages;
== Documentation ==
Each [https://github.com/ijpb/MorphoLibJ/releases released version of MorphoLibJ] comes with a [https://github.com/ijpb/MorphoLibJ/releases/download/v1.34.40/MorphoLibJ-manual-v1.34.40.pdf User Manual in PDF format].
The main source code directory is on GitHub under [http://github.com/ijpb/MorphoLibJ/tree/master/src/main/java/inra/ijpb src/main/java/inra/ijpb].