While in some cases, the threshold <math>T</math> can or should be selected manually by the user, there are many cases where the user wants the threshold to be automatically set by an algorithm. In those cases, the threshold should be the "best" threshold in the sense that itthe partition of the pixels above and below the threshold should separatematch inas twoclosely classesas possible the brighteractual objectspartition consideredbetween tothe betwo partclasses of objects represented by those pixels (e.g., pixels below the foregroundthreshold andshould correspond to the darkerbackground objectsand consideredthose above to besome partobjects of interest in the backgroundimage).
Many types of automatic thresholding methods exist, the most famous and widely used being [[Otsu's method]]. The following list, based on the works of [[#Sezgin2004|Sezgin et al. (2004)]] categorizes thresholding methods into broad groups based on the information the algorithm manipulates. Note however that such a categorization is necessarily fuzzy as some methods can fall in several categories (for example, Otsu's method can be both considered a histogram-shape and a clustering algorithm)
Line 23:
=== Global vs local thresholding ===
In most methods, the same threshold is applied to all the pixel of an image. However, in some cases, it can be advantageous to apply a different threshold to different parts of the image, based on the local informationvalue of the pixels. This category of methods is called local or adaptive thresholding. They are particularly adapted to cases where images have inhomogeneous lighting, such as in the sudoku image on the right. In those cases, a user-defined neighborhood is defined and a threshold is computed for each pixel and its neighborhood. Many global thresholding methods can be adapted to work in a local way, but there are also methods developed specifically for local thresholding, such as the Niblack<ref>{{Cite book |first=Wayne |last=Niblack |url=http://worldcat.org/oclc/1244113797 |title=An introduction to digital image processing |date=1986 |publisher=Prentice-Hall International |isbn=0-13-480600-X |oclc=1244113797}}</ref> or the Bernsen algorithms.
Software such as [[ImageJ]] propose a wide range of automatic threshold methods, both [https://imagej.net/plugins/auto-threshold global] and [https://imagej.net/plugins/auto-local-threshold local].