Thresholding (image processing)


In digital image processing, thresholding is the simplest method of segmenting images. From a grayscale image, thresholding can be used to create binary images.

Definition

The simplest thresholding methods replace each pixel in an image with a black pixel if the image intensity is less than some fixed constant T , or a white pixel if the image intensity is greater than that constant. In the example image on the right, this results in the dark tree becoming completely black, and the white snow becoming completely white.

Categorizing thresholding methods

To make thresholding completely automated, it is necessary for the computer to automatically select the threshold T. Sezgin and Sankur categorize thresholding methods into the following six groups based on the information the algorithm manipulates :
Colour images can also be thresholded. One approach is to designate a separate threshold for each of the RGB components of the image and then combine them with an AND operation. This reflects the way the camera works and how the data is stored in the computer, but it does not correspond to the way that people recognize colour. Therefore, the HSL and HSV colour models are more often used; note that since hue is a circular quantity it requires circular thresholding. It is also possible to use the CMYK colour model.

Probability distributions

Histogram shape-based methods in particular, but also many other thresholding algorithms, make certain assumptions about the image intensity probability distribution. The most common thresholding methods work on bimodal distributions, but algorithms have also been developed for unimodal distributions, multimodal distributions, and circular distributions.

Automatic thresholding

Automatic thresholding is a great way to extract useful information encoded into pixels while minimizing background noise. This is accomplished by utilizing a feedback loop to optimize the threshold value before converting the original grayscale image to binary. The idea is to separate the image into two parts; the background and foreground.
  1. Select initial threshold value, typically the mean 8-bit value of the original image.
  2. Divide the original image into two portions;
  3. # Pixel values that are less than or equal to the threshold; background
  4. # Pixel values greater than the threshold; foreground
  5. Find the average mean values of the two new images
  6. Calculate the new threshold by averaging the two means.
  7. If the difference between the previous threshold value and the new threshold value are below a specified limit, you are finished. Otherwise apply the new threshold to the original image keep trying.

    Note about limits and threshold selection

The limit mentioned above is user definable. A larger limit will allow a greater difference between successive threshold values. Advantages of this can be quicker execution but with a less clear boundary between background and foreground. Picking starting thresholds is often done by taking the mean value of the grayscale image. However, it is also possible to pick out the starting threshold values based on the two well separated peaks of the image histogram and finding the average pixel value of those points. This can allow the algorithm to converge faster; allowing a much smaller limit to be chosen.

Method limitations

Automatic thresholding will work best when a good background to foreground contrast ratio exists. Meaning the picture must be taken in good lighting conditions with minimal glare.