Thresholding (image processing)
Thresholding is the simplest method of image segmentation. From a grayscale image, thresholding can be used to create binary images (Shapiro, et al. 2001:83).
Method
During the thresholding process, individual pixels in an image are marked as “object” pixels if their value is greater than some threshold value (assuming an object to be brighter than the background) and as “background” pixels otherwise. This convention is known as threshold above. Variants include threshold below, which is opposite of threshold above; threshold inside, where a pixel is labeled "object" if its value is between two thresholds; and threshold outside, which is the opposite of threshold inside (Shapiro, et al. 2001:83). Typically, an object pixel is given a value of “1” while a background pixel is given a value of “0.” Finally, a binary image is created by coloring each pixel white or black, depending on a pixel's label.
Threshold selection
The key parameter in the thresholding process is the choice of the threshold value (or values, as mentioned earlier). Several different methods for choosing a threshold exist; users can manually choose a threshold value, or a thresholding algorithm can compute a value automatically, which is known as automatic thresholding (Shapiro, et al. 2001:83). A simple method would be to choose the mean or median value, the rationale being that if the object pixels are brighter than the background, they should also be brighter than the average. In a noiseless image with uniform background and object values, the mean or median will work well as the threshold, however, this will generally not be the case. A more sophisticated approach might be to create a histogram of the image pixel intensities and use the valley point as the threshold. The histogram approach assumes that there is some average value for the background and object pixels, but that the actual pixel values have some variation around these average values. However, this may be computationally expensive, and image histograms may not have clearly defined valley points, often making the selection of an accurate threshold difficult. One method that is relatively simple, does not require much specific knowledge of the image, and is robust against image noise, is the following iterative method:
- An initial threshold (T) is chosen, this can be done randomly or according to any other method desired.
- The image is segmented into object and background pixels as described above, creating two sets:
- = {f(m,n):f(m,n)>T} (object pixels)
- = {f(m,n):f(m,n)T} (background pixels) (note, f(m,n) is the value of the pixel located in the column, row)
- The average of each set is computed.
- = average value of
- = average value of
- A new threshold is created that is the average of and
- T’ = ( + )/2
- Go back to step two, now using the new threshold computed in step four, keep repeating until the new threshold matches the one before it (i.e. until convergence has been reached).
This iterative algorithm is a special one-dimensional case of the k-means clustering algorithm, which has been proven to converge at a local minimum—meaning that a different initial threshold may give a different final result.
Adaptive thresholding
Thresholding is called adaptive thresholding when a different threshold is used for different regions in the image. This may also be known as local or dynamic thresholding (Shapiro, et al. 2001:89).
Categorizing thresholding Methods
Sezgin and Sankur (2004) categorize thresholding methods into the following six groups based on the information the algorithm manipulates (Sezgin et al., 2004):
- "histogram shape-based methods, where, for example, the peaks, valleys and curvatures of the smoothed histogram are analyzed
- clustering-based methods, where the gray-level samples are clustered in two parts as background and foreground (object), or alternately are modeled as a mixture of two Gaussians
- entropy-based methods result in algorithms that use the entropy of the foreground and background regions, the cross-entropy between the original and binarized image, etc.
- object attribute-based methods search a measure of similarity between the gray-level and the binarized images, such as fuzzy shape similarity, edge coincidence, etc.
- [...] spatial methods [that] use higher-order probability distribution and/or correlation between pixels
- local methods adapt the threshold value on each pixel to the local image characteristics."
Multiband thresholding
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. An interesting new method uses the CMYK colour model to threshold colour images (Pham et al., 2007).
In histology images the colour is given by 2 or more dyes, for example hematoxylin and DAB. The contributions of these two dyes to the colour image can be established by using colour deconvolution. The incident light is measured by looking at an unstained part of the slide. Then you measure the relative absorption of each the 3 RGB components of the image by each dye. Absorption is defined by Beer's Law. The absorption characteristics for each dye can be obtained by measuring the RGB components of the colour in areas of the slide that are only coloured by one dye. The computer software can solve 3 linear equations for each pixel in the image, one for each colour channel, in order to resolve the amounts of each of the dyes at each locus in the image. This method can resolve up to 3 different dyes. The result is an image for each dye, showing the amount of that dye throughout the image. This allows the amount of dye to be quantified, which is important for image analysis of immunohistochemical stains.
See also
Citations
- Pham N, Morrison A, Schwock J et al. (2007). Quantitative image analysis of immunohistochemical stains using a CMYK color model. Diagn Pathol. 2:8.
- Shapiro, Linda G. & Stockman, George C. (2002). "Computer Vision". Prentice Hall. ISBN 0-13-030796-3
- Mehmet Sezgin and Bulent Sankur, Survey over image thresholding techniques and quantitative performance evaluation, Journal of Electronic Imaging 13(1), 146–165 (January 2004). doi:10.1117/1.1631315
References and further reading
- Gonzalez, Rafael C. & Woods, Richard E. (2002). Thresholding. In Digital Image Processing, pp. 595–611. Pearson Education. ISBN 81-7808-629-8