# Adaptive Thresholding

Adaptive thresholding is an image segmentation algorithm that appears quite resistent to varying lighting conditions.

This recent paper attempts to summarize and compare various image thresholding algorithms/techniques.

## Contents

**Global Value Adaptive Thresholding**

(useful for barrel-in-sunlight detection)

Below are various algorithms for *auto-thresholding*, that is, the process by which a threshold value on a histogram of a grayscale image is chosen automatically so as to fall in between the "foreground mound" and the "background mound" of the histogram. Once this threshold value is chosen, the "foreground" and "background" components of an image can be distinguished by comparing pixel values to the chosen threshold value.

### Otsu Thresholding

A somewhat technical overview of the Otsu algorithm can be found in section 2 of this paper. The same paper additionally proposes a modified version of the Otsu algorithm in section 3 that it asserts is less computationally expensive than the traditional Otsu algorithm.

Another paper's take on Otsu thresholding:

Ah ha! I've located the citation for Otsu's original paper:

#### Links

- Sample Image Filter
- Original Source Code
- Cleaned up Source Code by David

#### Progress

I've been trying to analyze the source code of this image filter (not written by me) in order to figure out how the Otsu Thresholding algorithm works. I've had limited success, in that I have completely figured out how *GrayLevelClass.java* works. However I have not been able to decode *OtsuThresholding.java* which appears to contain the essential details specific to the Otsu algorithm.
--David 21:14, 7 Nov 2005 (EST)

After several hours of work, I've finally decoded the Otsu algorithm! Not only that - I have written my own implementation of the algorithm which seems to produce good results when given sample images. To the right is a histogram augmented with a vertical red line indicating the thresholding level selected by the Otsu algorithm. In the near future I will incorporate the Otsu algorithm into the next ImageFilterDemo distribution. --David 16:01, 8 Nov 2005 (EST)

#### Implementation

I've implemented the Otsu algorithm in the **OtsuThresholdingAlgorithm** class, included with ImageFilterDemo v1.3.1. The **GrayscaleLevelHistogram** filter in ImageFilterDemo v1.3.2 uses this algorithm to calculate a threshold value which is displayed as a vertical red line on the output histogram. --David

#### Issues

- The Otsu algorithm is computationally expensive, according to a number of papers I have come across. Admittedly a number of these papers were written in the 1980s or earlier, but it is still a potential problem to keep in mind.
- The Otsu algorithm assumes (like many histogram-based algorithms) that its input histogram is bimodal. If, in fact, this is not the case - for example if the Otsu algorithm is applied to the
*unimodal*histogram of an image that does*not*contain the object of interest (like orange/white construction barrels) - the algorithm will perform poorly.- I have yet to resolve this issue but am actively researching a solution. --David 19:10, 9 Nov 2005 (EST)

### Maximum Entropy Thresholding

#### Links

Once again, I've tried to analyze the source code of this image filter in order to figure how the algorithm its using works. --David 21:27, 7 Nov 2005 (EST)

### Mixture Model Thresholding

#### Links

### Other Thresholding Algorithms

- Binary Clustering
- Metric
- Moment-Preserving Thresholding
- "Moment preserving thresholding is a parametric method which segments the image based on the condition that the thresholded image has the same moments as the original image." - taken from [1]

- Inner-class Variance
- Pun Thresholding

**Local Value Adaptive Thresholding**

(useful for line-on-grass detection)

### Other Thresholding Algorithms

- Niblack Thresholding
- Bernsen Thresholding
- Abutaleb Thresholding
- Sauvola Thresholding
- PirahanSiah Adaptive Single thresholding based on PSNR ( www.pirahansiah.com )

## Unassessed Thresholding Algorithms

- Lloyd Thresholding
- Ridler-Calvard Thresholding // Iterative Selection Thresholding
- Johannsen Entropy Thresholding
- Yen, Chang Thresholding
- Sahoo, Wilkins, Yeager Thresholding // Renyi's Entropy Thresholding
- Triangle Thresholding
- Kittler-Illingworth Thresholding // Minimum Error Thresholding
- Kapur, Sahoo, Wong Thresholding

## References

- A Fast Algorithm for Multilevel Thresholding
- Has a decent overview of the Otsu thresholding algorithm
- Proposes a more optimized version of the Otsu algorithm. From a quick skim of the new algorithm's description, it might be more memory intensive than the Otsu alogrithm (since extra lookup tables are involved).

- Decompose algorithm for thresholding degraded historical document images
- Has a very useful set of tables (on the third and fourth pages) that list the various common thresholding algorithms that have been developed since 2005.
- Proposes its own interesting thresholding algorithm that involves analyzing an image and then choosing one of the historical thresholding alogrithms to apply to it, based on the image's characteristics. (This algorithm would take way too long to implement, even though it is very good.)

- Original article proposing the Otsu thresholding algorithm