Thresholding (image processing)

The thresholding method is a set of algorithms for segmentation of digital images. Segmentation in general can be an important step for image analysis, for example to detect objects in the image. With the help of thresholding can decide in simple situations which pixels represent searched objects and which belong to its surroundings. Thresholding lead to binary images.

Introduction

Motivation for the use of binary images is usually the availability of fast binary algorithms, for example for blob analysis; the storage space savings plays in image processing applications, today a lesser role.

As with all segmentation methods are also used in the thresholding pixels - the so-called pixels - different groups - assigned - the so-called segments. The image to be segmented is present here in the form of numerical values ​​(one or more color values ​​per pixel). The membership of a pixel to a segment is decided by comparing the gray value or any other one-dimensional feature to a threshold. The gray value of a pixel is its pure brightness, more color information are not considered. Since this operation is generally applied independently to each pixel, the threshold method is a so-called pixel-based segmentation procedures.

Thresholding methods are among the oldest methods in digital image processing. The well-known, described in the same section of Otsu method was published in 1979 by Nobuyuki Otsu. However, there are still older publications on this topic. Thresholding can be implemented quickly due to its simplicity and segmentation results can be calculated with little effort. However, the quality of the segmentation is generally worse than that of more complex methods.

classification

An image segmentation is in the process of machine vision usually the first step of image analysis and is based on the preprocessing. The typical sequence in an image processing system is as follows:

Scene → Picture → Record → preprocessing segmentation (eg, thresholding ) → feature extraction → Classification → statement

The scene depicts a case or more real, observed objects dar. With suitable sensors an image of the scene is generated, usually a photograph or a video recording. In principle, however, any imaging techniques are used as the image source, so that for example, radar scans or X-rays come into question. If the image is not available in digital form, so it has to be digitized by scanning, for example, previously, in order to further process it in the calculator.

In the pre-processing the image is improved in that the following steps can be carried out more effectively. This may mean, for example, a brightness correction, it could improve the contrast or the edges are sharpened. What preprocessing operations are cheap, depends on the actual procedures in the following steps. Thresholding methods are generally susceptible to brightness changes in the image brightness compensation can therefore be beneficial.

In the segmentation step, the pixels of the image are divided into segments, for which, for example, a threshold is used. In the subsequent feature extraction for each segment certain characteristics - the characteristics of so-called - determined. What features are depends very much on the individual case. As examples of the surface, the eccentricity of the mold or of the mean color value can be mentioned.

Using the features and a predetermined set of rules or a previously trained classifier each segment can now be classified into one of several classes in the classification. Through an interpretation of this result can finally, a statement can be made, for example in the Text Recognition " In the imaged object is the letter 'f' and no other ."

Properties

Usually, the thresholding binarize an output image, which means it will be exactly two segments formed - in probably the most common use case for this method ideally the background and the objects sought. The assignment to the two segments ( 0 and 1) is based on a comparison of the gray value g of the considered pixel ( english threshold means " threshold ") with the predetermined threshold value t. The resulting image can thus be calculated with very little computational effort, since each pixel is only a simple compare operation must be performed. The corresponding calculation rule the figure is:

The thresholding methods are so-called complete segmentation method, that is, each pixel is assigned to a mandatory segment. They are also without overlap, so it will not have a pixel multiple segments. In contrast to many other segmentation method, the thresholding do not form contiguous segments. It is quite conceivable, and often wished that more spatially separate objects, are summarized in the image that have similar brightness value to a segment. In practice, it also comes regularly to false segmentations of individual pixels in the midst of objects, which is, for example, due to noise in the output image. The size of the segmented objects can vary greatly depending on the choice of the threshold value.

Variants

Regardless of the choice of the threshold value (as described in the corresponding section below ), the basic principle of thresholding be applied in various ways.

In global thresholding, a threshold is selected globally for the entire image. The corresponding calculation rule was further properties specified in the section above. The method is the easiest to calculate, but also very vulnerable to changes in brightness in the image.

Thresholding with global threshold are therefore used successfully in industrial applications only in high-contrast images. Such images arise, for example when scanning templates, or writing, taking pictures at transmitted light.

By setting a plurality of thresholds, the overall process can be varied so that the segmentation provides more than two segments. In this case, ( n-1) threshold values ​​Ti are required for n segments:

When local thresholding the original image is divided into regions and the threshold value for each region defined separately. This means that in each image region R, a suitable threshold Ti can be selected, without affecting the quality of the segmentation of other regions. The calculation rule for each pixel (x, y) is:

Compared with the global threshold method, the complexity increases only slightly, so the local method can also be calculated with low computational effort. Susceptibility to changes in brightness decreases, but it may come at the boundaries of regions to offset. Depending on the number of regions of the effort may be too high by a human to select the appropriate threshold for each region. An automatic procedure for the choice of the threshold value is therefore advisable.

As a further development of the local procedure can view the dynamic thresholding the a neighborhood N considered for each pixel, and based on this neighborhood an appropriate threshold t is calculated (N). Here, an automatic method to select the threshold value is necessary. The corresponding calculation rule for each pixel (x, y) is:

The dynamic version is quite stable with respect to local changes in brightness. The computational effort increases significantly but here, since for each pixel, a new threshold is calculated.

Example

  • Noise image

And ... the associated histogram (logarithmic scale).

The sample image is a noisy grayscale image with blurred edges, as can be seen on the left. Blurry edges here means that the edges are not clear, but undergo a transition from white background to black object and in this case assume the pixels in the edge region of different shades of gray.

The choice of the picture matching threshold the associated histogram helps ( on the right ). A histogram shows the frequency of each gray value is indicated by a correspondingly high line. As a legend, therefore, a bar with the different gray values ​​is on the horizontal coordinate axis depicted above is then respectively by the height of the line, the relative frequency of occurrence of each gray value specified.

The histogram clearly two peaks can be seen: The dark object (left peak ) and the bright background (right peak ). Also, each gray value between the two maxima is obviously present in the image, which is caused by the noise in the image and the soft edges of objects where the pixel gradually assume the different shades of gray from white to black.

The output image was segmented with the global thresholding method for the demonstration of the result image for four different threshold values ​​was calculated. In the resulting binary images with two groups of segments, each pixel has been colored according to its assignment to the object or to the background black ( 0 ) or white ( 1). More: All pixels with gray values ​​less than the threshold were colored black, all pixels with gray values ​​greater than or equal to the threshold white accordingly.

  • Segmentation with different threshold

Threshold 52

Threshold 204

Threshold 230

In its segmentation with the 30 threshold several belonging to the object pixels are colored white, so segmented to the background. The threshold was therefore set too low.

With the two threshold values ​​52 and 204 arise fairly decent results. This also applies to all the thresholds between these two values. The difference is it can be seen that the object with increasing threshold is slightly larger. The choice of the threshold value so not only has influence on the quality of the segmentation itself, but also on the sizes of the segmented surfaces. Reason for the growth of the area, the pixels in the edge area covering the gray scale values ​​of white to black gradually.

The threshold 230 segmented some background pixels as belonging to the object. This is an indication that he was too large.

Choice of the threshold value

The crux of all thresholding methods is the choice of an appropriate threshold. This can be used judiciously by a human editor. However, since a greater number is required at the local threshold and dynamic threshold method, it is advisable to use an automatic method for the determination of the threshold values ​​. Of course, the threshold at the global thresholding can be determined automatically. There are a large number of specific method for selecting a suitable threshold value.

Both the manual and the automatic determination of a threshold value, the histogram is the most important tool. Local maxima indicate the gray values ​​or gray value ranges that are adopted from the background or from larger objects in the image. In the ideal case, the histogram is bimodal, that is, it can be detected two distinctly separate peaks. A simple, but also more error-prone approach is to choose the midpoint between the two maxima as a threshold. Another simple approach is to set the gray value of the minimum between the maxima as a threshold. This would probably have a slightly better separation achieved.

You edit pictures again and again from the same source, you can often apply a once selected threshold to all these images.

One of the more sophisticated method for the automatic determination of threshold values ​​is the method of Otsu, which has established itself as a standard and is to be presented below.

Method of Otsu

The method according to Nobuyuki Otsu Otsu in 1979 uses statistical tools to solve the problem of the best possible threshold. In particular, use is made of the variance, which is a measure of the scatter of values ​​- in this case it is about the spread of the gray values.

The method of Otsu determines a threshold value, wherein the dispersion, between the classes but is as small as possible within the given class at the same time by as large as possible. For this purpose, the ratio between the two variances is formed and a threshold sought in which these as large as possible (maximum) is.

Mathematical representation

As a starting point are two classes of points, ( and ) that are separated from each other due to this threshold value. this is the desired variable, the two classes are the desired result. Below a level determined by the method of Otsu, after the threshold value (and thus the class ) may be optimized.

It is the probability of occurrence of the gray value 0 < g < G ( G is the maximum gray value ). Then the probability of the occurrence of pixels of the two classes obtained with:

With the adoption of two classes (ie, a threshold ) is the sum of these two probabilities Naturally 1

If the arithmetic mean of the gray values ​​within the entire image, and and the mean values ​​within each class, then the variances within the two classifications are as:

The goal now is to keep the variance of the gray values ​​in the individual classes to a minimum, while the variance between the classes to be as large as possible. Results in the following quotient:

This is the variance between the classes:

The variance within each class results from the sum of the two individual variances:

The threshold value is then selected such that the ratio becomes maximum. So the desired degree. If a threshold value is determined by maximizing the quotient, it shall communicate the point sets corresponding to the variance in optimal classes.

Problems

  • Brightness Problems

The associated histogram ... (linear scale ) ...

And ... the result of the segmentation with the 127 threshold

The global thresholding is very susceptible to changes in brightness across the image. The three pictures demonstrate this problem: The original image (left) was equipped with a brightness curve. The histogram (middle image ) is no longer bimodal, as in the example above, there can be no two clearly separated maxima make, but there are many more, quite small local maxima. The resulting image (right) of segmentation with the 127 threshold shows to be unstable: Top left whole background regions are segmented as the object while the object is recognized as a background bottom right. Only in the middle of the screen determines the segmentation roughly.

The application of the local or even the dynamic threshold method could improve the segmentation result here. However, the latter is particularly clearly computationally expensive. It must also be ensured that in each region all appear to be segmented objects, otherwise the automatically selected threshold values ​​could be calculated incorrectly. If there is, for example, three objects (and the background) to recognize in the picture, three thresholds are chosen to separate the four classes from each other. Diving in a region but only two of the three objects, then the third threshold value can there not be correctly determined. The result of the segmentation of this region is so do not go well with the results of other regions. An alternative solution would be to compensate for the brightness in a pre-processing step, for example with a shading correction or by offsetting a reference image.

Next brightness profiles, other image defects, which can cause problems in the segmentation can be eliminated or reduced by an appropriate pre-processing. Frequently used denoising of images or the sharpening of edges. Also, a post-processing can help eliminate segmentation problems. So wrong segmented pixels can be corrected by humans or by suitable filtering.

In contrast to many other segmentation methods do not automatically result in the threshold- contiguous segments, with stronger noise almost always individual pixels are segmented out.

The thresholding always use only one-dimensional image information ( usually an intensity value or gray level ). Additional information, such as different color channels are not evaluated.

Some of these problems can be prevented by other, partly more complex, methods are used for segmentation.

Applications

The thresholding methods are very suitable for fast binarization (separation of subject and background ) of evenly lit images such as scans. This means, for example, a good aptitude for the first step of a text recognition.

When editing function, it is found in many image editing programs, such as GIMP, IrfanView and ImageJ.

Thresholding method also represent standard methods in digital image processing and included in each program library in this area.

626862
de