home rightup

---

Thresholding

Common Names: Threshold, Density slicing

Brief Description

In many vision applications, it is useful to be able to separate out the regions of the image corresponding to objects in which we are interested, from the regions of the image that correspond to background. Thresholding often provides an easy and convenient way to perform this segmentation on the basis of the different intensities or colors in the foreground and background regions of an image.

In addition, it is often useful to be able to see what areas of an image consist of pixels whose values lie within a specified range, or band of intensities (or colors). Thresholding can be used for this as well.

How It Works

The input to a thresholding operation is typically a grayscale or color image. In the simplest implementation, the output is a binary image representing the segmentation. Black pixels correspond to background and white pixels correspond to foreground (or vice versa). In simple implementations, the segmentation is determined by a single parameter known as the intensity threshold. In a single pass, each pixel in the image is compared with this threshold. If the pixel's intensity is higher than the threshold, the pixel is set to, say, white in the output. If it is less than the threshold, it is set to black.

In more sophisticated implementations, multiple thresholds can be specified, so that a band of intensity values can be set to white while everything else is set to black. For color or multi-spectral images, it may be possible to set different thresholds for each color channel, and so select just those pixels within a specified cuboid in RGB space. Another common variant is to set to black all those pixels corresponding to background, but leave foreground pixels at their original color/intensity (as opposed to forcing them to white), so that that information is not lost.

Guidelines for Use

Not all images can be neatly segmented into foreground and background using simple thresholding. Whether or not an image can be correctly segmented this way can be determined by looking at an intensity histogram of the image. We will consider just a grayscale histogram here, but the extension to color is trivial.

If it is possible to separate out the foreground of an image on the basis of pixel intensity, then the intensity of pixels within foreground objects must be distinctly different from the intensity of pixels within the background. In this case, we expect to see a distinct peak in the histogram corresponding to foreground objects such that thresholds can be chosen to isolate this peak accordingly. If such a peak does not exist, then it is unlikely that simple thresholding will produce a good segmentation. In this case, adaptive thresholding may be a better answer.

Figure 1 shows some typical histograms along with suitable choices of threshold.




Figure 1 A) shows a classic bi-modal intensity distribution. This image can be successfully segmented using a single threshold T1. B) is slightly more complicated. Here we suppose the central peak represents the objects we are interested in and so threshold segmentation requires two thresholds: T1 and T2. In C), the two peaks of a bi-modal distribution have run together and so it is almost certainly not possible to successfully segment this image using a single global threshold

The histogram for image

wdg2

is

wdg2hst1

This shows a nice bi-modal distribution --- the lower peak represents the object and the higher one represents the background. The picture can be segmented using a single threshold at a pixel intensity value of 120. The result is shown in

wdg2thr3

The histogram for image

wdg3

is

wdg3hst1

Due to the severe illumination gradient across the scene, the peaks corresponding to foreground and background are blended together and so simple thresholding does not give good results. Images

wdg3thr1   and   wdg3thr2

show the resulting bad segmentations for single threshold values of 80 and 120 respectively (reasonable results can be achieved by using adaptive thresholding on this image).

Thresholding is also used to filter the output of or input to other operators. For instance, in the former case, an edge detector like Sobel will highlight regions of the image that have high spatial gradients. If we are only interested in gradients above a certain value (i.e. sharp edges), then thresholding can be used to just select the strongest edges and set everything else to black.


As an example, consider again :

wdg2

Applying to it the Sobel (gradient) operator produces :

wdg2


which, when thresholded (at a value of 60) gives the binary image:


wdg2


Adaptive Thresholding ...

Thresholding can be used as preprocessing to extract an interesting subset of image structures which will then be passed along to another operator in an image processing chain. For example, image

cel4

shows a slice of brain tissue containing nervous cells (i.e. the large gray blobs, with darker circular nuclei in the middle) and glia cells (i.e. the isolated, small, black circles). We can threshold this image so as to map all pixel values between 0 and 150 in the original image to foreground (i.e. 255) values in the binary image, and leave the rest to go to background, as in

cel4thr1

The resultant image can then be connected-components-labeled in order to count the total number of cells in the original image, as in

cel4lab1

If we wanted to know how many nerve cells there are in the original image, we might try applying a double threshold in order to select out just the pixels which correspond to nerve cells (and therefore have middle level grayscale intensities) in the original image. (In remote sensing and medical terminology, such thresholding is usually called density slicing.) Applying a threshold band of 130 - 150 yields

cel4thr2

While most of the foreground of the resulting image corresponds to nerve cells, the foreground features are so disconnected (because nerve cell nuclei map to background intensity values along with the glia cells) that we cannot apply connected components labeling. Alternatively, we might obtain a better assessment of the number of nerve cells by investigating some attributes (e.g. size, as measured by a distance transform) of the binary image containing both whole nerve cells and glia. In reality, sophisticated modeling and/or pattern matching is required to segment such an image.

Interactive Experimentation

You can interactively experiment with this operator by clicking here.

Exercises

  1. How would you set up the lighting for a simple scene containing just flat metal parts viewed from above so as to ensure the best possible segmentation using simple thresholding?

  2. In medical imagery of certain mouse nervous tissue, healthy cells assume a medium graylevel intensity, while dead cells become dense and black. The images
    cla3

    clb3

    and

    clc3

    were each taken on a different day during an experiment which sought to quantify cell death. Investigate the intensity histogram of these images and choose a threshold which allows you to segment out the dead cells. Then use connected components labeling to count the number of dead cells on each day of the experiment.

  3. Thresholding is often used in applications such as remote sensing where it is desirable to select out, from an image, those regions whose pixels lie within a specified range of pixel values. For instance, it might be known that wheat fields give rise to a particular range of intensities (in some spectral band) that is fairly unusual elsewhere. In the multi-spectral image
    aer1

    assume that wheat fields are visible as yellow patches. Construct a set of thresholds for each color channel which allow you to segment out the wheat fields (note, you may need to reset your display).

  4. How should the intensity threshold be chosen so that a small change in this threshold value causes as little change as possible to the resulting segmentation? Think about what the intensity histogram must look like at the threshold value.

  5. Discuss whether you expect thresholding to be of much use in segmenting natural scenes.

References

E. Davies Machine Vision: Theory, Algorithms and Practicalities, Academic Press, 1990, Chap. 4.

R. Gonzalez and R. Woods Digital Image Processing, Addison-Wesley Publishing Company, 1992, Chap. 7.

D. Vernon Machine Vision, Prentice-Hall, 1991, pp 49 - 51, 86 - 89.

Local Information

Specific information about this operator may be found here.

More general advice about the local HIPR installation is available in the Local Information introductory section.

---

home rightup

©2003 R. Fisher, S. Perkins, A. Walker and E. Wolfart.

Valid HTML 4.0!