Landini Threshold - Automatic Segmentation

Implementation of a method for automatic adaptive local thresholding and segmentation of greyscale images.
Updated 28 Dec 2022

View License

This is an implementation of the algorithm developed by:
G. LANDINI, D. A. RANDELL, S. FOUAD & A. GALTON, "Automatic thresholding from the gradients of region boundaries", Journal of Microscopy, Vol. 265, Issue 2 2017, pp. 185–195
"We present an approach for automatic threshold segmenta-tionofgreyscaleimages.Theprocedureisinspiredbyareinter-pretation of the strategy observed in human operators whenadjusting thresholds manually and interactively by means of‘slider’ controls. The approach translates into two methods.The first one is suitable for single or multiple global thresh-olds to be applied globally to images and consists of searchingfor a threshold value that generates a phase whose bound-ary coincides with the largest gradients in the original image.The second method is a variation, implemented to operate onthe discrete connected components of the thresholded phase(i.e. the binary regions) independently. Consequently, this be-comes an adaptive local threshold procedure, which operatesrelative to regions, rather than to local image subsets as is thecaseinmostlocalthresholdingmethodspreviouslypublished.Adding constraints for specifying certain classes of expectedobjects in the images can improve the output of the methodover the traditional ‘segmenting first, then classify’ approach"
Example usage:
Amin = min particle area to detect
Amax = max particle area to detect
Cmin = min particle circularity to detect
Lmin = Lower threshold grayscale level
Lmax = Upper threshold grayscale level
For very large images the "for" in line 46 can be swapped for "parfor" if you have the paralel computing toolbox. This will speed up the algorithm.
I = imread('coins.png');
Rfill = Landini_Threshold(I,Amin,Amax,Cmin,Lmin,Lmax);

Cite As

Robin Hartley (2024). Landini Threshold - Automatic Segmentation (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2022b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes

Fixed bug which prevented blobs that overlapped with the image edge from being detected


Update citation