# What are the most common algorithms for adaptive thresholding?

Adaptive thresholding has been discussed in a few questions earlier:

Adaptive Thresholding for liver segmentation using Matlab

What are the best algorithms for document image thresholding in this example?

Of course, there are many algorithms for Adaptive thresholding. I want to know which ones you have found most effective and useful.

Which Adaptive algorithms you have used the most and for which application; how do you come to choose this algorithm?

-
+1 Im curious to know. –  Mohammad May 18 '12 at 15:00

I do not think mine will be a complete answer, but I'll offer what I know and since this is a community edited site, I hope somebody will give a complimentary answer soon :)

Adaptive thresholding methods are those that do not use the same threshold throughout the whole image.

But, for some simpler usages, it is sometimes enough to just pick a threshold with a method smarter than the most simple iterative method. Otsu's method is a popular thresholding method that assumes the image contains two classes of pixels - foreground and background, and has a bi-modal histogram. It then attempts to minimize their combined spread (intra-class variance).

The simplest algorithms that can be considered truly adaptive thresholding methods would be the ones that split the image into a grid of cells and then apply a simple thresholding method (e.g. iterative or Otsu's method) on each cell treating it as a separate image (and presuming a bi-modal histogram). If a sub-image can not be thresholded good the threshold from one of the neighboring cells can be used.

Alternative approach to finding the local threshold is to statistically examine the intensity values of the local neighborhood of each pixel. The threshold is different for each pixel and calculated from it's local neighborhood (a median, average, and other choices are possible). There is an implementation of this kind of methods included in OpenCV library in the cv::adaptiveThresholding function.

I found another similar method called Bradley Local Thresholding. It also examines the neighborhood of each pixel, setting the brightnes to black if the pixels brightness is t percent lower than the average brightness of surrounding pixels. The corresponding paper can be found here.

This stackoverflow answer mentiones a local (adaptive) thresholding method called Niblack but I have not heard of it before.

Lastly, there is a method I have used in one of my previous smaller projects, called Image Thresholding by Variational Minimax Optimization. It is an iterative method, based on optimizing an energy function that is a nonlinear combination of two components. One component aims to calculate the threshold based on the position of strongest intensity changes in the image. The other component aims to smooth the threshold at the (object)border areas. It has proven fairly good on images of analog instruments (various shading and reflection from glass/plastic present), but required a careful choice of the number of iterations.

Late edit: Inspired by the comment to this answer. There is one more way I know of to work around uneven lighting conditions. I will write here about bright objects on a dark background, but the same reasoning can be applied if the situation is reverse. Threshold the white top-hat transform of the image with a constant threshold instead of the original image. A white top hat of an image is nothing but a difference between the image $f$ and it's opening $\gamma(f)$. As further explanation let me offer a quote from P. Soille: Morphological Image Analysis:

An opening of the original image with a large square SE removes all relevant image structures but preserves the illumination function. The white top-hat of the original image or subtraction of the illumination function from the original image outputs an image with a homogeneous illumination.

-
I just saw the "how did you choose..." part of the question... trial and error, progressing from the simplest to the more complex methods –  penelope May 30 '12 at 11:51
+1 Very comprehensive answer. Just the way i wanted. –  Dipan Mehta May 30 '12 at 12:31

You can find a paper containing a comparison of a number of thresholding methods here:

• M. Sezgin, B. Sankur - Survey over image thresholding techniques and quantitative performance evaluation, Journal of Electronic Imaging, 2004 - pdf

Here's another paper evaluating binarization methods:

• P. Stathis, E. Kavallieratou and N. Papamarkos - An Evaluation Technique for Binarization Algorithms, Journal of Universal Computer Science, 2008, - pdf

The adaptive binarization method I have used in my last project uses integral images for fast computation of the threshold function used by the Sauvola method. The Sauvola method is described in:

• J. Sauvola and M. Pietikainen, Adaptive document image binarization, Pattern Recognition 33, 2000. - pdf

The modification which uses integral images providing a 20-fold speedup (according to the paper) is described in this paper:

• F. Shafait, D. Keysers, and T. M. Breuel, Efficient implementation of local adaptive thresholding techniques using integral images, Document Recognition and Retrieval XV, 2008 - pdf

These are just the papers I used when choosing the binarization method for my project (for finding text in images). I'm not an expert so I can't say which method is the best for which application.

-