Image segmentation

    Image segmentation


    One of the main tasks of image processing and analysis is segmentation, i.e. dividing the image into areas for which a certain uniformity criterion is fulfilled, for example, highlighting areas of approximately the same brightness on the image. The concept of the image area is used to determine a connected group of image elements having a certain common attribute (property).
    One of the main and simple ways is to build a segmentation using a threshold. A threshold is a sign (property) that helps to divide the desired signal into classes. The operation of the threshold separation is to compare the brightness value of each pixel in the image with the specified threshold value.


    Binarization


    The operation of threshold separation, which results in a binary image, is called binarization. The purpose of the binarization operation is to drastically reduce the amount of information contained in the image. In the process of binarization, the initial grayscale image having a certain number of brightness levels is converted into a black and white image, the pixels of which have only two values ​​- 0 and 1.

    Threshold image processing can be carried out in different ways.

    Binarization with a lower threshold

    Binarization with a lower threshold
    Binarization with a lower threshold is the simplest operation, in which only one threshold value is used:

    All values ​​instead of the criterion become 1, in this case 255 (white) and all values ​​(amplitudes) of pixels that are greater than the threshold t - 0 ( the black).

    Binarization with an upper threshold
    Sometimes it is possible to use a variant of the first method, which gives a negative image obtained in the process of binarization. Upper Threshold


    Binarization Operation: Double-Constrained Binarization
    To highlight areas in which pixel brightness values ​​can vary in a known range, a double-constraint binarization is introduced (t 12):

    Other variations with thresholds are also possible, where only part of the data is skipped (middle-pass filter).

    Incomplete threshold processing
    This transformation produces an image that may be easier for further analysis, since it becomes devoid of background with all the details present in the original image.

    Multilevel threshold transformation
    This operation generates an image that is not binary, but consists of segments with different brightness.


    As for binarization, that's basically it. Although you can add that there is a global one that is used for the entire image and there is also a local one that captures part of the picture (image).

    Local threshold processing

    Ots
    Method The method uses a histogram of the distribution of pixel brightness values ​​of a raster image. A histogram is constructed using the values ​​p i = n i / N, where N is the total number of pixels in the image, n i is the number of pixels with brightness level i. The brightness range is divided into two classes using the threshold value of the brightness level k, k is an integer value from 0 to L. Each class corresponds to the relative frequencies ω 0 ω 1 :

    Average levels for each of the two image classes:
    Next, the maximum value for evaluating the image separation quality is calculated into two parts:
    where (σ cl ) 2 = ω 0 ω 110 ) 2 , is the interclass variance, and (σ total ) 2 is the total variance for the whole image.

    Determining the threshold based on the brightness gradient of the image
    Suppose that the analyzed image can be divided into two classes - objects and background. The algorithm for calculating the threshold value consists of the following 2 steps:
    1. The module of the brightness gradient is determined for each pixel in the
    image

    2. Calculation of the threshold:


    Method for using the histogram entropy
    The method has acquired its various forms of description and possible variations. Distributions of the total mass of thresholds by a certain amount using various laws and forms of distribution.
    Global Threshold Processing

    Burnsen's method
    1. An ordinary square aperture with an odd number of pixels runs in a cycle through all the pixels of the original image. Every step is Min and Max.
    2. The average value Avg = (Min + Max) / 2 is found.
    3. If the current pixel is larger than Avg 4. If the average is less than the contrast threshold, then the current pixel becomes the color specified by the “color of the doubtful pixel” parameter.
    It has a number of disadvantages: after processing monotonous brightness areas, strong spurious interference is formed, in some cases it leads to the appearance of false black spots
    .
    One of the most productive methods is the Eikvel method. It is often used for processing clear and contrasting images. According to this method, the image is processed using two concentric windows: small - S, and large L. Typically, the shape of the windows is assumed to be square. Both windows are superimposed from left to right from top to bottom on the image in increments equal to the side of the small window S. For window L, threshold B is calculated so that the pixels are divided into two clusters. If the mathematical expectations of the brightness level in the two clusters have a difference exceeding some user-defined level / μ 12 / ≥l, then all the pixels inside the window S are binarized according to the threshold T. Otherwise, the brightness of the pixels from the window S is replaced by some close value.
    The Nibble Method
    The idea of ​​this method is to vary the brightness threshold B of the binarization from point to point based on the local standard deviation. The brightness threshold at the point (x, y) is calculated as follows:

    where μ (x, y) is the mean and s (x, y) is the standard deviation of the sample for some neighborhood of the point. The size of the neighborhood should be minimal, but such as to preserve local details of the image. At the same time, the size should be large enough to reduce the effect of noise on the result. The value of k determines which part of the boundary of the object to take as the object itself. A value of k = -0.2 defines a fairly good separation of objects if they are presented in black, and a value of k = + 0.2, if objects are represented in white.
    The Janowitz and Brookstein Method
    The potential surface based on local maximization of the brightness gradient is used as the threshold surface of binarization. The beginning of the luminance gradient is often calculated using the Sobel or Canny loop operator. The image is filtered in order to obtain contour lines with a thickness of 1 pixel, and then a 3 × 3 averaging filter. The potential surface, now, is constructed according to an iterative interpolating scheme. The calculation of the surface is in order, starting from the outline pixels. For each non-contour pixel, the interpolation residue R (x, y) is calculated and the new pixel value P (x, y) at step n + 1 should be calculated in accordance with the formulas:

    β within 1≤β≤2 for fast convergence.

    Total

    I found it with pleasure I laid out to you, in the future, if it works out and there will be time, I will try to implement some of the algorithms. This is only a small part of everything that exists today, but I am glad to share this.
    Thanks for attention.

    Also popular now: