Skip to content, Skip to search

Changes

MorphoLibJ

6,053 bytes added, 6 February
Particle analysis: update plugin name (particle -> region)
| 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
| latest version = August 25October 23<sup>thrd</sup>, 2016 2018 ([[MorphoLibJ]] v1.34.0)
| status = stable, active
| category = [[:Category:Analysis|Analysis]], [[:Category:Filtering|Filtering]], [[:Category:Segmentation|Segmentation]], [[:Category:Mathematical_morphology|Mathematical morphology]]
}}{{TOC}}Collection MorphoLibJ is a collection of [[wikipedia:Mathematical morphology|mathematical morphology]] methods and '''plugins''' for ImageJ, created at [http://www-ijpb.versailles.inra.fr/en/bc/equipes/modelisation-imagerie/ INRA-IJPB Modeling and Digital Imaging lab].
The library implements several functionalities that were missing in ImageJ, and that were not or only partially covered by other plugins. Namely:
| publisher = Academic Press
| year = 1982
| doi = 10.1002/cyto.990040213}}</ref>; Serra ''et al.'', 1992<ref name="Serra1992>{{ cite conferencejournal
| title = An overview of morphological filtering
| author = Serra, Jean and Vincent, Luc
| year = 1992
| publisher = Springer
| doi = 10.1007/BF01189221
}}</ref>). The most basic morphological filters are the '''morphological dilation''' and the '''morphological erosion'''. The principle of morphological dilation is to test for each point of the plane, if the structuring element centered on this point '''intersects''' the structure of interest (see figure below). It results in a set larger than the original set.
The principle of morphological erosion is to test for each point of the plane if the structuring element centred on this point '''is contained''' within the original set. It results in a set smaller than original set.
| number = 11
| pages = 1313-1329
| journal =IEEE Transactions on Pattern Analysis and Machine Intelligence| doi = 10.1109/34.969120}}</ref>; Heneghan ''et al.'', 2002<ref name="Heneghan2002">{{ cite journal
| title = Characterization of changes in blood vessel width and tortuosity in retinopathy of prematurity using image analysis
| author = Conor Heneghan and John Flynn and Michael O Keefe and Mark Cahill
| year = 2002
| publisher = Elsevier
| doi = 10.1016/S1361-8415(02)00058-0
}}</ref>; Hendriks ''et al.'', 2003<ref name="Hendriks2003">{{ cite conference
| title = Discrete Morphology with Line Structuring Elements
| author = Hendriks, CL Luengo and van Vliet, Lucas J
| booktitle = International Conference on Computer Analysis of Images and Patterns
| pages = 722-729,| year = 2003,
| organization = Springer
| doi = 10.1007/978-3-540-45179-2_88
}}</ref>). For example, applying a median filter or a morphological opening with horizontal direction results in the enhancement of horizontal parts of bright structures. Similarly, using a vertical structuring element results in the enhancement of the vertical portions of the structures.
==== Usage ====
The geodesic reconstruction algorithm is often used within other operators. In MorphoLibJ, it is however provided as a plugin to allow its inclusion in user-designed macros or plugins:
* '''Geodesic Reconstruction''': compute the geodesic reconstruction by erosion or dilation using a marker image and a mask image, and a specified connectivity.* '''Interactive Geodesic Reconstruction''': compute the geodesic reconstruction by erosion or dilation taking the current 2D image as mask image, creating the marker image out of user-defined ROIs (for example with the point selection tool).and using a specified connectivity. The plugin allows previewing the result.
* '''Geodesic Reconstruction 3D''': compute the geodesic reconstruction by erosion or dilation on a 3D image.
* '''Interactive Geodesic Reconstruction 3D''': compute the geodesic reconstruction by erosion or dilation on using the current 3D image as mask and creating the marker image from the user-defined point selections.
The kill borders and fill holes operations are also provided as plugins. Both work for 2D and 3D images of 8, 16 or 32 bits.
* '''Kill Borders''': remove the particles touching the border of a binary or grayscale image.
* '''Fill Holes''' remove holes inside particles in binary images, or remove dark regions surrounded by bright crests in grayscale images.
 
=== Regional and extended extrema ===
'''Regional minima''' are defined as connected regions of elements (pixels or voxels) with the same value, and whose neighboring elements all have values greater than that of the region. Similarly, '''regional maxima''' are regions of connected pixels or voxels with same value, whose neighbors all have smaller value.
[[Image:Classic-Watershed-lines-blur-blobs.png|thumb|200px|Overlay of watershed lines on blurred blobs.]] The watershed algorithm assimilates the grey level image to a digital elevation model, and aims at detecting the different catchment basins. In the grey-level image, the catchment basins correspond to dark regions surrounded by bright structures (the "crests"). It is a very popular technique specially used to segment touching objects. The MorphoLibJ suite contains several implementations of the algorithm and plugins that make use of it:
* [[Classic Watershed]], plugin implementing the original watershed algorithm by Pierre Soille and Luc M. Vincent (1990) <ref name="Soille1990>{{ cite conference| title = Determining watersheds in digital pictures via flooding simulations| author = Soille, Pierre and Vincent, Luc M| booktitle = Proc. SPIE| volume = 1360| pages = 240-250| year = 1990| organization = International Society for Optics and Photonics| doi = 10.1117/12.24211| url = http://dx.doi.org/10.1117/12.24211}}</ref> to segment 2D/3D grayscale images.* [[Marker-controlled Watershed]], a plugin to perform watershed in 2D/3D images by flooding from specific seed points or markers by Meyer and Beucher (1990)<ref name="Meyer1990>{{ cite journal| title = Morphological segmentation| author = F. Meyer and S. Beucher| journal = Journal of Visual Communication and Image Representation| volume = 1| number = 1| pages = 21-46| year = 1990| doi = 10.1016/1047-3203(90)90014-M| url = http://www.sciencedirect.com/science/article/pii/104732039090014M}}</ref>.* [[Interactive Marker-controlled Watershed]], a plugin to perform watershed in 2D/3D images by flooding from specific seed points or markers introduced interactively by the user.
* [[Morphological Segmentation]], a plugin with a graphical user interface to segment 2D/3D images based on morphological operations and the watershed algorithm.
* [[Distance Transform Watershed]], two plugins (2D and 3D) that work on binary images and allow to separate touching objects by combining the distance transform and watershed methods.
== 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.
For 3D particles, intrinsic volumes correspond to the volume, the surface area, the mean breadth (a quantity proportional to the integral of the mean curvature over the surface) and the Euler number. In 3D the Euler number equals the number of connected components minus the number of "handles" or "tunnels" through the structure, plus the number of bubbles within the particles (Serra, 1982<ref name="Serra1982>{{ cite conference| title = Image Analysis and Mathematical Morphology. Volume 1| author = Serra, Jean| publisher = Academic Press| year = 1982}}</ref>; Ohser ''et al.'', 2009<ref name="Osher2009>{{ cite conference| title booktitle = 3D Images of Materials Structures: processing and analysis| title = Image Processing
| author = Joachim Ohser and Katja Schladitz
| publisher = WILEYWiley-VCH Verlag GmbH \& Co. KGaA, Weinheim| year = 2009| isbn doi = 978-3-527-31203-010.1002/9783527628308.ch4| url = http://dx.doi.org/10.1002/9783527628308.ch4
}}</ref>).
In image analysis, the '''estimation of area''' of 2D particles and of '''volume of 3D particles''' simply consists in counting the number of pixels or voxels that constitute it, weighted by the area of an individual pixel or the volume of an individual voxel.
The implemented method for '''perimeter measurement''' aims at providing a better estimate of the perimeter than traditional boundary pixel count. The principle is to consider a set of lines with various orientations, and to count the number of intersections with the region(s) of interest (see figure on the right). The number of intersections is proportional to the perimeter (Serra, 1982<ref name="Serra1982>{{ cite conference| title = Image Analysis and Mathematical Morphology. Volume 1| author = Serra, Jean| publisher = Academic Press| year = 1982}}</ref>; Legland ''et al.'', 2007<ref name="Legland2007">
{{cite conference
|title = Computation of Minkowski measures on 2D and 3D binary images
|doi = 10.5566/ias.v26.p83-92
|url = http://www.ias-iss.org/ojs/IAS/article/view/811
}}</ref>; Ohser ''et al.'', 2009<ref name="Osher2009>{{ cite conference| title = 3D Images of Materials Structures: processing and analysis| author = Joachim Ohser and Katja Schladitz| publisher = WILEY-VCH Verlag GmbH \& Co. KGaA, Weinheim| year = 2009| isbn = 978-3-527-31203-0}}</ref>). By averaging over all possible directions, the estimate is unbiased.
Perimeter can be estimated using either two directions (horizontal and vertical), or four directions (by adding the diagonals). Restricting the number of directions introduces an estimation bias, with known theoretical bounds (Moran, 1966<ref name="Moran1966">
|doi = 10.1093/biomet/53.3-4.359
|URL = http://biomet.oxfordjournals.org/content/53/3-4/359.abstract
}}</ref>; Legland ''et al.'', 2007<ref name="Legland2007">{{cite conference|title = Computation of Minkowski measures on 2D and 3D binary images|author = Legland, David and Kiêu, Kiên and Devaux, Marie-Françoise|journal = Image Analysis and Stereology|year = 2007|month = June|number = 6|pages = 83-92|volume = 26|doi = 10.5566/ias.v26.p83-92|url = http://www.ias-iss.org/ojs/IAS/article/view/811}}</ref>), that is usually better than boundary pixel count (Lehmann ''et al.'', 2012<ref name="Lehmann2012">{{cite conferencejournal
|title = Efficient N-Dimensional surface estimation using [[wikipedia:Crofton formula|Crofton formula]] and run-length encoding
|author = Lehmann, Gaetan and Legland, David
}}</ref>).
The '''estimation of surface area''' follows the same principle. The number of directions is typically chosen equal to 3 (the three main axes in image), or 13 (by considering also diagonals). As for perimeter estimation, surface area estimation in usually biased, but is usually more precise than measuring the surface area of the polygonal mesh reconstructed from binary images (Lehmann ''et al.'', 2012<ref name="Lehmann2012">{{cite conference|title = Efficient N-Dimensional surface estimation using [[wikipedia:Crofton formula|Crofton formula]] and run-length encoding|author = Lehmann, Gaetan and Legland, David|journal = Insight Journal|year = 2012|pages = 1-11|url = http://hdl.handle.net/10380/3342}}</ref>).
=====Euler number=====
The measurement of Euler number depends on the choice of the connectivity. For planar images, typical choices are the 4-connectivity, corresponding to the orthogonal neighbors, and the 8-connectivity, that also considers the diagonal neighbors. In 3D, the 6-connectivity considers the neighbors in the three main directions within the image, whereas the 26 connectivity also considers the diagonals. Other connectivities have been proposed but are not implemented in MorphoLibJ (Ohser ''et al.'', 2009<ref name="Osher2009>{{ cite conference| title = 3D Images of Materials Structures: processing and analysis| author = Joachim Ohser and Katja Schladitz| publisher = WILEY-VCH Verlag GmbH \& Co. KGaA, Weinheim| year = 2009| isbn = 978-3-527-31203-0}}</ref>).
In the current implementation in MorphoLibJ, the Euler number is not taken into account for intersection of particles with image borders. This may result in non-integer result if the particle(s) of interest touches the image border.
::::::::<math>circularity=4\pi\frac{A}{P^{2}}</math>
While values of circularity range theoretically within the interval <math>[0;1]</math>, the measurements errors of the perimeter may produce circularity values above 1 (Lehmann ''et al.'', 2012<ref name="Lehmann2012">{{cite conference|title = Efficient N-Dimensional surface estimation using [[wikipedia:Crofton formula|Crofton formula]] and run-length encoding|author = Lehmann, Gaetan and Legland, David|journal = Insight Journal|year = 2012|pages = 1-11|url = http://hdl.handle.net/10380/3342}}</ref>). The MorphoLibJ library also considers the inverse of the circularity, referred to as "elongation index". The values of elongation range from 1 for round particles and increase for elongated particles.
::::::::<math>elongation = \frac{P^{2}}{4\pi\cdot A}</math>
* '''yi''': the y-coordinate of the inscribed circle.
* '''radius''': the radius of the inscribed circle.
[[Image:Longest-geodesic-path-DRIVE.png|thumb|300px|right|Computation of the geodesic diameter on a segmented image from the DRIVE database (Staal ''et al''., 2004<ref name="Staal2004">{{ cite conferencejournal
|title = Ridge based vessel segmentation in color images of the retina
| author = J.J. Staal and M.D. Abramoff and M. Niemeijer and M.A. Viergever and B. van Ginneken
* '''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 <math>S</math> and a target image <math>T</math>, 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 <math>r</math>:
:<math>TO_{r}=\frac{|S_{r}\cap T_{r}|}{|T_{r}|}</math>
* Total Overlap (for all regions):
:<math>TO=\frac{\sum_{r}{|S_{r}\cap T_{r}|}}{\sum_{r}{|T_{r}|}}</math>
* [https://en.wikipedia.org/wiki/Jaccard_index Jaccard Index] or Union Overlap for each individual labeled region <math>r</math>:
:<math>UO_{r}=\frac{|S_{r}\cap T_{r}|}{|S_{r}\cup T_{r}|}</math>
* [https://en.wikipedia.org/wiki/Jaccard_index Jaccard Index] or Union Overlap for all regions:
:<math>UO=\frac{\sum_{r}|S_{r}\cap T_{r}|}{\sum_{r}|S_{r}\cup T_{r}|}</math>
* [https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient Dice Coefficient] or Mean Overlap for each individual labeled region <math>r</math>:
:<math>MO_{r}=2\frac{|S_{r}\cap T_{r}|}{|S_{r}|+|T_{r}|}</math>
* [https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient Dice Coefficient] or Mean Overlap for all regions:
:<math>MO=2\frac{\sum_{r}|S_{r}\cap T_{r}|}{\sum_{r}\left(|S_{r}|+|T_{r}|\right)}</math>
* Volume Similarity for each individual labeled region <math>r</math>:
:<math>VS_{r}=2\frac{|S_{r}|-|T_{r}|}{|S_{r}|+|T_{r}|}</math>
* Volume Similarity for all regions:
:<math>VS=2\frac{\sum_{r}\left(|S_{r}|-|T_{r}|\right)}{\sum_{r}\left(|S_{r}|+|T_{r}|\right)}</math>
* False Negative Error for each individual labeled region <math>r</math>:
:<math>FN_{r}=\frac{|T_{r}\setminus S_{r}|}{|T_{r}|}</math>
* False Negative Error for all regions:
:<math>FN=\frac{\sum_{r}|T_{r}\setminus S_{r}|}{\sum_{r}|T_{r}|}</math>
* False Positive Error for each individual labeled region <math>r</math>:
:<math>FP_{r}=\frac{|S_{r}\setminus T_{r}|}{|S_{r}|}</math>
* False Positive Error for all regions:
:<math>FP=\frac{\sum_{r}|S{}_{r}\setminus T{}_{r}|}{\sum_{r}|S_{r}|}</math>
=== Spatial organization ===
==Binary and label image utilities==
The MorphoLibJ library provides several utility functions for the processing and the management of binary and label images.All methods of this section are available as plugins under {{bc | Plugins | MorphoLibJ | Binary Images}} or {{bc | Plugins | MorphoLibJ | Label Images}}. === Utilities Distances for binary images=======Distance transform====When analyzing images, it is often necessary to compute distances to a particular structure or position. A convenient operator for binary images is the '''distance transform'''. Its principle is to compute, for each foreground pixel, the distance to the nearest background pixel. The result is commonly referred to as '''Distance Map'''. [[Image:MorphoLibJ-distance-transform-on-binary-leaf.png|thumb|700px|center|Binary image, and result of computation of the distance transform.]] Several methods exist for computing distance maps. The MorphoLibJ library implements distance transforms based on chamfer distances, that approximate Euclidean distances but are simpler to compute. * '''Chamfer Distance Map''' computes an approximate distance map from a binary image between each foreground pixel to the nearest background pixel.* '''Chamfer Distance Map 3D''' computes an approximate distance map from a 3D binary image between each foreground voxel to the nearest background voxel. ====Geodesic distance transform==== In some cases it may be useful to restrict the propagation of distances to a specific region or mask. For example, one may be interested in the distance between two points in a vasculature network, while staying within the network. The '''geodesic distance transform''' consists in computing the distance from a given binary marker, while constraining the propagation of the distance within a binary mask. An illustration is given in the figure below: [[Image:MorphoLibJ-geodesic-distance-example.png|thumb|500px|center|Computation of the geodesic distance map on a binary image from the DRIVE database (Staal ''et al.'', 2004<ref name="Staal2004" />). Left: original image with marker superimposed in red. Right: result of geodesic distance map, hot colors correspond to large distances, cold colors correspond to small distances.]] * '''Geodesic Distance Map''' computes the geodesic distance between each foreground pixel of a binary mask image to the closest pixel of a marker image, while staying within the particle represented by the mask image.* '''Interactive Geodesic Distance Map''' computes the geodesic distance between each foreground pixel of a the currently selected image (considered the mask image) to the closest pixel of a marker image defined by the user ROIs, while staying within the particle represented by the mask image. ===Label images===When several structures or components are present within an image, it may be more convenient to work with label images. Each pixel or voxel of a label image corresponds to the integer index of the particle it belongs to. The value 0 is assumed to correspond to the background. The number of labels that can be represented depends on the image type: 255 for byte images, 65535 for short images ... Label images can be represented either using shades of gray, or using color maps to better distinguish the different regions.  ====Connected component labeling====The different structures within a binary images can be labeled by using a connected component labeling algorithm. Each label will correspond to a set of connected pixels or voxels.  
[[Image:MorphoLibJ-grains-binary-label-distance.png|thumb|700px|right|Binary image, result of connected components labeling, and computation of distance map on the complement of binary image.]]
Some functions Different connectivities may be chosen. For planar images, the most current ones are specific for the processing 4-connectivity, that consider only orthogonal neighbors of binary a given pixel, and the 8-connectivity, that also considers the diagonals. For 3D images, namely:the 6-connectivity considers only orthogonal neighbors in the three main directions, whereas the 26-connectivity considers all the direct neighbors of a given voxel. 
* '''Connected Components Labeling''' transforms the binary image into a label image by assigning a specific number (label) to each connected component.
* '''Chamfer Distance Map''' computes an approximate distance map from a binary ====Label image between each foreground pixel representation====Several plugins allow to control the nearest background pixelappearance of label images.* '''Geodesic Distance Map''' computes the geodesic distance between each foreground pixel of It is possible to choose a given color map, or to transform a binary mask label image to the closest pixel of into a marker color image. In both cases, while staying within the particle represented by background color can be specified, and the color order can be shuffled to facilitate the mask imagediscrimination of neighbor regions with similar labels. [[Image:MorphoLibJ-geodesicgrains-distancelabels-exampleassign-measure.png|thumb|350px480px|rightcenter|Computation Assign result of the geodesic distance map on a binary measurement to a label image from . In this example, the DRIVE database elongation is represented using a color code, between dark purple (circular) to yellow (Staal very elongated).]] * '''Assign Measure To Label'et al.'', 2004<ref name="Staal2004" />). Left: original combines a label image with marker superimposed in red. Right: result of geodesic distance mapa results table, hot colors correspond and creates a new image for which each pixel/voxel is assigned the measurement value corresponding to large distances, cold colors correspond the label it belongs to small distances.]]* '''Chamfer Distance Set Label Map 3D''' computes an approximate distance allows to choose the color map from used to display a label image. In particular, shuffling the color map and/or choosing a specific color for background allows better visualization that only grey levels.* '''Label To RGB''' converts a 3D binary label image to true RGB image . Similar to ImageJ native conversion, but this plugin avoids confusion between each foreground voxel to the nearest background voxelpixels and regions with low labels. ===Region and labels selection===The MorphoLibJ library offers several tools for automatically select binary regions or labels based on size or position criteria.====Binary images====
* '''Keep / Remove Largest Region''' identifies the largest connected component, and keeps it or removes it.
* '''Size Opening''' computes the size (area in 2D, volume in 3D) of each connected component, and remove all particles whose size is below the value specified by the user.
Algorithms work for both 2D or 3D images. Default connectivity 4 (resp. 6) is used for 2D (resp. 3D) images.
=== Utilities for label =Label images ===Some functions are specific for the processing of label images, in which the pixel/voxel value is used to identify the particle it belongs to. The value 0 is assumed to correspond to the background. The number of labels that can be represented depends on the image type: 255 for byte images, 65535 for short images...=
[[Image:MorphoLibJ-grains-binary-label-remove-border-largest-size-opening.png|thumb|700px|center|MorphoLibJ utilities for label images. From left to right: original label image, remove border labels, remove largest region, apply size opening for keeping only regions with at least 150 pixels.]]
* '''Select Label(s)''' enters a set of labels, and creates a new label image containing only the selected labels.
* '''Crop Label''' creates a new binary image containing only the label specified by the user. The size of the new image is fitted to the region.
* '''Replace Value/Remove Label(s)''' replaces the value of a region by another value. Can be used to “clear” a label, by replacing its value by 0, or to merge to adjacent regions.
* '''Label Boundaries''' creates a new binary image containing value 255 for pixels/voxels having a neighbour with a different value.
* '''Keep / Remove Largest Label''' identifies the largest label, and keeps it or removes it.
* '''Label Size Opening''' computes the size (area in 2D, volume in 3D) of each region, and removes all labels whose size is below the value specified by the user.
* '''Assign Measure To Label''' combines a label image with a results table, and creates a new image for which each pixel/voxel is assigned the measurement value corresponding to the label it belongs to.
* '''Set Label Map''' allows to choose the color map used to display a label image. In particular, shuffling the color map and/or choosing a specific color for background allows better visualization that only grey levels.
* '''Label To RGB''' converts a label image to true RGB image. Similar to ImageJ native conversion, but this plugin avoids confusion between background pixels and regions with low labels.
[[Image:MorphoLibJ-grains-labels-assign-measure.png|thumb|480px|center|MoprphoLibJ: assign result of a measurement to a label image. In this example, the elongation is represented using a color code, between dark purple (circular) to yellow (very elongated).]]
=== Label Edition plugin ===
<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() );
// and show itoptimize display rangeImages3D.optimizeDisplayRange( resultImage );// set same slice as inputresultImage.showsetSlice( imp.getCurrentSlice() );</source>
</source>
==== Label visualization in 3D viewer ====
Making use of MorphoLibJ's label methods and the [[3D_Viewer|ImageJ 3D Viewer]]'s visualization tools it is quite simple to create a script to display each label of an image as 3D surfaces of the corresponding colors provided by the image look-up table:
<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.0/MorphoLibJ-manual-v1.4.0.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].
== Installation ==
* In [[ImageJ1.x]], download the [https://github.com/ijpb/MorphoLibJ/releases latest released jar] into the ''plugins'' folder. * In [[ImageJ2]] (including [[Fiji]]), you just need to [[How_to_follow_a_3rd_party_update_site#Add_update_sites | add]] the IJPB-plugins site to your list of update sites: ::: 1) *# Select {{bc | Help | Update...}} from the Fiji menu to start the [[updater]]::: 2) *# Click on ''Manage update sites''. This brings up a dialog where you can activate additional update sites. ::: 3) *# Activate the IJPB-plugins update site and close the dialog. Now you should see an additional jar file for download.*# Click ''Apply changes'' and restart ImageJ.
::: 4) Click ''Apply changes'' and restart Fiji.
== Citation ==
Please note that [[MorphoLibJ]] is based on a publication. If you use it successfully for your research please be so kind to cite our work:
* David Legland, Ignacio Arganda-Carreras, and Philippe Andrey. [http://bioinformatics.oxfordjournals.org/content/early/2016/07/19/bioinformatics.btw413 {{Publication | MorphoLibJ: integrated library and plugins for mathematical morphology with ImageJ]. Bioinformatics, btw413, 2016.}}
[[MorphoLibJ]]'s code repository has its own [https://zenodo.org/badge/latestdoi/21349/ijpb/MorphoLibJ DOI].
Emailconfirmed, incoming, administrator, uploaders
2,581
edits