Thresholding Filters

In digital image processing, thresholding is one of the simplest methods of segmenting images. Basic thresholding methods replace each pixel in an image with a black pixel if the image intensity 'I' is less than some fixed constant 'T', or a white pixel if the image intensity is greater than that constant. In the example below, this results in the lower grayscale values becoming completely black, and higher grayscale values becoming completely white.

Original image (left) and after simple threshold applied (right)

Thresholding example

Thresholding algorithms implemented in Dragonfly can be separated into the following categories:

Simple thresholding… For every pixel, the same threshold value is applied. If the pixel value is smaller than the threshold, it is set to 0, otherwise it is set to a maximum value.

Adaptive thresholding… In cases in which using a global value as a threshold might not be adequate, for example when working with images with varying illumination, adaptive thresholding can be applied. In this case, methods to adapt the threshold value on each pixel to the local image characteristics are applied. This results in a different threshold being selected for each pixel in the image. You should note that adaptive thresholding often requires more computation time than simple thresholding.

If you are not familiar with the details of the different algorithms and the underlying assumptions, it can be difficult to know which algorithm will give the best results. In these cases, experimenting with the different options available will usually result in finding the best algorithm for your purposes.

Thresholding filters output an image composed of two basic classes — foreground and background. These images can be used as masks for segmentation purposes or for other image processing tasks.

Thresholding filters and settings
  What it does Options
Adaptive Applies an adaptive threshold to images based on local pixel neighborhood, in which all pixels in the input image higher than the corresponding pixel in the threshold image are considered foreground. The threshold value is the weighted mean for the local neighborhood of a pixel subtracted by a constant.

References
[1] http://scikit-image.org/docs/dev/api/skimage.filters.html?highlight=adaptive%20filter#threshold-adaptive

Kernel size
Method of thresholding
Offset
Isodata Computes threshold value(s) based on the ISODATA method. That is, returned thresholds are intensities that separate the image into two groups of pixels, where the threshold intensity is midway between the mean intensities of these groups.

References
[1] Ridler, T.W. and Calvard, S., Picture thresholding using an iterative selection method, 1978.
[2] IEEE Transactions on Systems, Man and Cybernetics 8: 630-632, (http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4310039).
[3] Sezgin M. and Sankur B., Survey Over Image Thresholding Techniques and Quantitative Performance Evaluation, Journal of Electronic Imaging, 13(1): 146-165, 2004, (http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf).
[4] http://scikit-image.org/docs/dev/api/skimage.filters.html?highlight=adaptive%20filter#threshold-isodata

- -
Li Computes the threshold value based on an adaptation of Li's Minimum Cross Entropy method.

References
[1] http://scikit-image.org/docs/dev/api/skimage.filters.html?highlight=adaptive%20filter#threshold-li

- -
Liu-Song-S Accurately and efficiently segments an image with a unimodal gray-level distribution by analyzing the morphology of the gray gradient distribution histogram.

Original image (left) and the result of Liu‐Song‐S thresholding (right)

Liu-Song-S filter

References
[1] Song et al, A new automatic thresholding algorithm for unimodal gray-level distribution images by using the gray gradient information, Volume 190, July 2020 (https://www.sciencedirect.com/science/article/abs/pii/S0920410520301674).

-
Local Otsu Performs local Otsu thresholding on an image, with a user-specified kernel size. Facilitates the threshold-segmentation of images with uneven illumination, without the need for background normalization, and for which global thresholding is inadequate. Kernel size
Mean Selects the threshold as the mean of the local greyscale distribution. -
Minimum Selects the threshold as the minimum of the local greyscale distribution. -
Niblack Applies a Niblack local threshold to an array. Instead of calculating a single global threshold for the entire image, several thresholds are calculated for every pixel by using specific formulae that take into account the mean and standard deviation of the local neighborhood (defined by a window centered around the pixel).

Note Refer to Niblack, W (1986), An introduction to Digital Image Processing, Prentice-Hall for more information.

Window size
k
Otsu This filter is an implementation of the Otsu thresholding technique and outputs an image composed of two basic classes — foreground and background. In this thresholding technique, the optimal value that minimizes the weighted within class variances of these two classes is computed. You should note that minimizing the within class variance is the same as maximizing the between class variance.

One of the main advantages of the Otsu thresholding technique is speed. However, the technique assumes uniform illumination and doesn’t use any object structure or spatial coherence. Since Otsu thresholding operates over histograms, you should analyze the image histogram before applying this filter (see Plotting Histograms from Annotations).

References
[1] https://en.wikipedia.org/wiki/Otsu%27s_method
[2] http://scikit-image.org/docs/dev/api/skimage.filters.rank.html?highlight=otsu%20filter#skimage.filters.rank.otsu

-
Sauvola

Implements Sauvola's thresholding method, which is a variation of Niblack's method.

References
[1] https://github.com/scikit-image/scikit-image/blob/v0.22.0/skimage/filters/thresholding.py#L1109
[2] J. Sauvola and M. Pietikainen, Adaptive document image binarization, Pattern Recognition 33(2), pp. 225-236, 2000 (https://doi.org/10.1016/S0031-3203(99)00055-2)

Window size
k
Triangle

Returns a threshold value based on the triangle algorithm.

References
[1] https://github.com/scikit-image/scikit-image/blob/v0.22.0/skimage/filters/thresholding.py#L897
[2] Zack, G. W., Rogers, W. E. and Latt, S. A., Automatic Measurement of Sister Chromatid Exchange Frequency, Journal of Histochemistry and Cytochemistry 25 (7), 1977, pp. 741-753 (https://doi.org/10.1177/25.7.70454)

-
Yen Computes the threshold value based on Yen’s method.

References
[1] http://scikit-image.org/docs/dev/api/skimage.filters.html?highlight=adaptive%20filter#threshold-yen
[2] Yen J.C., Chang F.J., and Chang S., A New Criterion for Automatic Multilevel Thresholding, IEEE Trans. on Image Processing, 4(3): 370-378, 1995.
[3] Sezgin M. and Sankur B., Survey over Image Thresholding Techniques and Quantitative Performance Evaluation, Journal of Electronic Imaging, 13(1): 146-165, 2004 (http://www.busim.ee.boun.edu.tr/~sankur/SankurFolder/Threshold_survey.pdf).

-