This page is a part of the Computer Vision Wiki. The wiki is devoted to computer vision, especially low level computer vision, digital image analysis, and applications. The exposition is geared towards software developers, especially beginners. The wiki contains discussions, mathematics, algorithms, code snippets, source code, and compiled software. Everybody is welcome to contribute with this in mind - all links are no-follow.

# Thresholding

In a binary image 0 is black and 1 is white. A gray scale image can represented by an array of numbers between 0 and 1. In practice, however, gray scale images are tables of integers. The integers normally run from 0 (black) to 255 (white).

These numbers together form the gray scale function of the image. An example is on the right.

A grayscale image.
The gray scale function of the image on the left.

The image on the left is accompanied by its gray scale function. Higher means lighter and lower means darker.

Now recall our approach:

Every image is represented as a combination of binary images.
Pixels with the gray values below the threshold are "black".

Thresholding is the following procedure that creates binary images from the gray scale image. We call these images frames:

```Given a number, threshold, T between 0 and 255,
create a T-th frame by replacing all the pixels
with gray level lower than or equal to T with black (0),
the rest with white (1).
```

Converting a gray scale image to a binary image is a common technique in image analysis. By thresholding of a gray scale image normally is understood the following procedure. Given a number, threshold, T between 0 and 255, create the binary image by replacing all the pixels with gray level in the original image lower than or equal to T with black.

As you raise the threshold, the number of black pixels increases, as in the images above.

Another illustration of thresholding is here [1].

The methods of finding the best threshold are the subject of an enormous amount of research. We will not deal with this issue. Instead we threshold the image for each possible value of T and accept the resulting sequence of binary images as a representation of the original.

Color Images can also be thresholded...