## Aa

where H(T) is the histogram function. The threshold that maximizes the average boundary gradient is selected.

If an image contains more than two types of regions, it may still be possible to segment it by applying several individual thresholds , or by using a multithresholding technique . With the increasing number of regions, the histogram modes are more difficult to distinguish, and threshold selection becomes more difficult.

Global thresholding is computationally simple and fast. It works well on images that contain objects with uniform intensity values on a contrasting background. However, it fails if there is a low contrast between the object and the background, if the image is noisy, or if the background intensity varies significantly across the image.

2.2 Local (Adaptive) Thresholding

In many applications, a global threshold cannot be found from a histogram or a single threshold cannot give good segmentation results over an entire image. For example, when the background is not constant and the contrast of objects varies across the image, thresholding may work well in one part of the image, but may produce unsatisfactory results in other areas. If the background variations can be described by some known function of position in the image, one could attempt to correct it by using gray level correction techniques, after which a single threshold should work for the entire image. Another solution is to apply local (adaptive) thresholding [6,9,18,25, 41,63,80,127].

Local thresholds can be determined by (1) splitting an image into subimages and calculating thresholds for each subimage, or by (2) examining the image intensities in the neighborhood of each pixel. In the former method , an image is first divided into rectangular overlapping subimages and the histograms are calculated for each subimage. The subimages used should be large enough to include both object and background pixels. If a subimage has a bimodal histogram, then the minimum between the histogram peaks should determine a local threshold. If a histogram is unimodal, the threshold can be assigned by interpolation from the local thresholds found for nearby subimages. In the final step, a second interpolation is necessary to find the correct thresholds at each pixel.

In the latter method, a threshold can be selected using the mean value of the local intensity distribution. Sometimes other statistics can be used, such as mean plus standard deviation, mean of the maximum and minimum values [16,25], or statistics based on local intensity gradient magnitude [25,62].

Modifications of the above two methods can be found in Refs. [30,41,80,96]. In general, local thresholding is computationally more expensive than global thresholding. It is very useful for segmenting objects from a varying background, and also for extraction of regions that are very small and sparse.

### 2.3 Image Preprocessing and Thresholding

Many medical images may contain low-contrast, fuzzy contours. The histogram modes corresponding to the different types of regions in an image may often overlap and, therefore, segmentation by thresholding becomes difficult. Image preprocessing techniques can sometimes help to improve the shape of the image histogram, for example by making it more strongly bimodal. One of the techniques is image smoothing by using the mean (average) or median filter discussed in Chapter 1 [53,65,96,99]. The mean filter replaces the value of each pixel by the average of all pixel values in a local neighborhood (usually an Nby N window, where N = 3, 5, 7, etc.). In the median filter, the value of each pixel is replaced by the median value calculated in a local neighborhood. Median smoothing, unlike the mean filter, does not blur the edges of regions larger than the window used while smoothing out small textural variations. Figure 4 illustrates FIGURE 4 Median filtering as a preprocessing step for thresholding; (A) original autoradiography image, (B) result of a 7 x 7 median filter, (C) result of a 9 x 9 median filter. Corresponding image histograms are shown on the right.

results of preprocessing on an autoradiography image using a median filter with 7x7 and 9x9 windows. Figure 4A shows the original image and its histogram, which is unimodal and, therefore, precludes selection of an appropriate threshold. Median filtering sharpens the peaks on the image histogram (Figs 4B and C) and allows selection of thresholds for image segmentation.

A common smoothing filter is the Gaussian filter, where for each pixel [i, j], the convolution mask coefficients g[i, j] are based on a Gaussian function:

where a is the spread parameter (standard deviation) that defines the degree of Gaussian smoothing: Larger a implies a wider Gaussian filter and a greater amount of smoothing. The Gaussian filter can be approximated in digital images by an N by N convolution mask. A 7 x 7 Gaussian mask with a2 = 2  is obtained with the coefficients of the following matrix:

0 0