Navigation : Home : FoveaPro : FoveaPro Tutorial : Part 13

Image Analysis Cookbook 6.0:  Part 13



4.A.2. Automatic methods

A wide range of automatic methods for thresholding are available. Selecting the appropriate technique is based on prior knowledge about the sample and image (e.g., that there are just two phases present, or that boundaries should be smooth). In many cases thresholding does not produce a precise delineation of the desired structure and further post processing will be needed (discussed below in Section 5).

The most common class of automatic tools work with the histogram, and do not consider the values of neighboring pixels. These are primarily statistical in nature and were originally developed for thresholding print on paper as a preliminary to optical character recognition. A typical assumption is that there are two classes of pixels (white paper and black ink) and that the threshold that best separates them divides the histogram into two groups in such a way that a statistical test such as the student’s t-test returns the highest probability that they are different groups. As shown in the example, that does a pretty good job for ink on paper ( IP•Threshold–>Bilevel Thresholding–>Auto ). Notice in the dialog that the histogram in this case does not have two peaks, but instead there is one large peak for the white paper and a long irregularly shaped tail for the dark ink.

droppedImage.pict

Automatic threshold selection in the bilevel thresholding dialog applied to Document image.

The plug-in offers additional algorithms for automatic threshold selection, each of which makes slightly different assumptions about the nature of the distribution of brightness values and applies different statistical tests to the histogram.

droppedImage.pict

If the automatic procedure is applied to the Zirconia image shown above, it selects a threshold that correctly splits the area into 60%-40%. Note that the threshold point is not an obvious one from the visual appearance of the histogram (not the lowest point, or midway between the peaks, etc.)

droppedImage.pict

A different approach to automatic thresholding uses information about the spatial distribution of pixels as well as their brightness values. One typical criterion is that the borders of the thresholded regions should be smooth, which corresponds to samples in which membranes, surface tension or other physical effects are expected to produce boundaries that are smooth (it would not apply, for example, to fractured concrete particles which are fractal and rough, but is very appropriate for the fat droplets in mayonnaise shown in the example). The IP•Threshold–>Threshold Levels plug-in offers this algorithm to refine an initial setting by up to ±16 grey levels from the user selection (click on the “Perimeter” button). Again, there are several other algorithms that can be selected but tests indicate that the “smoothest perimeter” criterion often corresponds to the setting chosen manually by experienced users.

droppedImage.pict

The Threshold Levels dialog applied to the fat droplets in the Mayo image

It is often useful to keep in mind that further processing after thresholding may be required, and that the requirements of the thresholding operation can sometimes be relaxed. In the following example, the boundaries between the grains in the metal are atomically narrow, but appear broad because of the chemical etching used in sample preparation. Thinning down the boundaries to single-pixel lines will be performed using skeletonization (discussed in the next section). Consequently, the threshold value can be set over a relatively broad range (which changes the width of the as-thresholded boundary lines) without affecting the final result.

droppedImage.pict droppedImage.pict

Gr_Steel image (fragment) after leveling brightness Thresholded binary image

droppedImage.pict

After skeletonization

4.A.3. Selecting a color range

Thresholding of color images can be performed using the same routines as for grey scale, but then only the intensity of each pixel is considered. Usually the color information is important for selection and should be used. In either RGB or HSI space, a range of colors can be specified to select structures for linearization. The built-in Photoshop color selection routine ( Select–>Color Range ) allows clicking on the image to specify the color of interest and shows the selected pixels. The “fuzziness” slider operates equally on the R, G and B channels and controls the degree of selection. After accepting the result, the image shows selection lines (“marching ants”) that can be used to create a binary image by filling the selection with black, inverting the selection, and filling the background with white. (The Photoshop alpha channel allows pixels to be fractionally selected; the selection marquee corresponds to the 50% selection boundary.)

droppedImage.pict image-594.pict

The Color Range selection dialog applied to the MandM image, and the resulting selection

More individual control over the red, green and blue color ranges is possible by thresholding the channels individually. The individual results are combined with a Boolean AND to select pixels whose red, green and blue values all lie within the selected range. To illustrate the logic involved, it is useful to examine the channels individually. In the example, the yellow spots are selected by thresholding the red and green channels for pixels that have high intensities in both.

image-595.pict image-428.png

Original ColrDots image, and the yellow spots defined by Boolean AND of thresholded red and green

image-429.png image-596.pict

Red channel and thresholded spots with high red intensity

image-430.png image-597.pict

Green channel and thresholded spots with high green intensity

In most cases, the combination of red, green and blue intensities that define colors is not obvious (for example, consider the brown spots in the previous image). Hue-Saturation-Intensity space provides a much more user-friendly way to perceive and define color. The IP•Threshold–>Threshold HSI plug-in represents this color space graphically as shown in the example. Marking out a region on the Hue-Saturation circle (the angle corresponds to the hue, the radius to the saturation; the darkness of locations represents the number of pixels with those values), and setting limits on the intensity axis, select pixels shown in the preview (clicking on a point in the preview marks the corresponding color coordinates as well). Notice in the example that brown is characterized not as a combination of red, green and blue, but rather as a dark, low-saturation red.

droppedImage.pict

Selecting the brown spots in the ColrDots image

Once the user is familiar with thresholding in HSI coordinates, it is efficient to select a color range using the IP•Threshold–>Color Tolerance routine. Clicking on the image with the eyedropper tool selects a color of interest. Then the tolerances in hue, saturation and intensity can be independently set to define the regions of interest.

droppedImage.pict

Selecting the color of interest and setting a color tolerance range ( Alloy image)

Sometimes only a single axis in the HSI coordinate space is needed, usually the hue information because most stains and fluorescing dyes are selected because of their characteristic color (hue). Extracting just the hue channel from the image ( IP•Color–>Color Filter ) and applying the Bi-Level Thresholding or Threshold Levels plug-in to the resulting greyscale image can then provide an efficient and automatic procedure for obtaining the desired binary image. In the example, the automatic bi-level thresholding method is used because there are just two colors of stain added to the tissue.

image-603.pict image-431.png

Original Intestine image Hue channel (contrast expanded)

image-432.png

Automatic bi-level thresholding result

For color or other multi-channel images, more powerful techniques for separating the various structures or phases to allow thresholding are available using the Principal Components Analysis routines. After transforming to principal components space, the channels can be thresholded just the same as the “regular” color channels.