830 Digital Image Processing (Gonzalez Edition) Postgraduate Notes (2): Derivation of Histogram Equalization Transformation Function, Use of Histogram Equalization and Analysis of Its Incomplete Flatness

Foreword


    The histogram is the statistics of the frequency of gray levels of an image. When normalized, it is equivalent to the probability distribution of each gray level. Histogram equalization is a way to use the histogram characteristics of an image to automatically improve the image quality. Through the transformation function, some gray levels with a low frequency of occurrence are merged, so that the frequency gap of each gray level after processing is reduced. To get a relatively uniform histogram. After histogram equalization, the histogram of an image will have a wider dynamic range, and the distribution of gray levels is more uniform. These are the characteristics that a high-contrast image usually has.


Image and Histogram


     For darker images, the lower gray level accounts for the majority, that is, the main components in the histogram are concentrated at the lower end of the gray level, and the brighter image is the opposite. For images with medium gray scale and low contrast, the main components of their histograms are concentrated in the narrow area in the middle of the gray scale. For images with medium grayscale and high contrast, their histograms basically cover the entire grayscale range and are evenly distributed. [2015 Zhenti Question 2]

    The histogram covers a wide range, and the images with a relatively uniform distribution of gray levels are usually high-contrast images, and such images often meet our requirements. Therefore, if one histogram has a narrow coverage area and uneven distribution of gray levels to another image with a wide histogram coverage and uniform distribution of gray levels, image enhancement can often be achieved, and This mapping process is histogram equalization. Histogram equalization needs a mapping function s = T (r) from r to s to complete the operation. The following will prove that the mapping function is the cumulative distribution function of the original image normalized histogram.


Mapping function derivation


                      

    As mentioned earlier, the normalized histogram is the probability distribution of each gray level, and now it is continuous for ease of analysis, and it becomes a probability density function. The left picture is the original probability density function, and the right picture is what we want. The new probability density function formed by transforming the original probability density function through the mapping function, it is easy to see that it follows a uniform distribution.

    From the knowledge of probability theory, the total area of ​​the two is the same. And to establish a relationship between the two, they also need area as a medium. If the area of ​​a small curved edge trapezoid in the left figure is equal to the area of ​​a rectangular bar in the right figure, a functional relationship between r and s can be established, as shown in equation (1). There is more left and less complement. If the function value in the left picture is large, dr will be greater than ds, if the function value in the left picture is small, dr will be greater than ds.

                                                           

    Let s = T (r) and be derivable, then formula (1) can be transformed into formula (2)

                                                 

    Integrate both sides of the equation on 0-r at the same time to get equation (3). Since the variable upper limit integral variable and the integral variable often use different letters to avoid confusion, and changing the integral variable does not change the integral value, here the integral variable is changed to w .

                                                 

    Solutions have to

                                                  

    It can be seen that for the probability density function of r on [0, L-1], as long as all r are mapped to s through the mapping function s = T (r), then there will be s in [0, L-1 ] Follows a uniform distribution, where T (r) is the cumulative distribution function of the probability density of r times (L-1). 【Question 10 of 2010 Zhenti】


Histogram Equalization


    The amplitude of the digital image is quantized, not continuous. The quantized image has a gray level. The 8-bit 256-level gray level is commonly used. Although it cannot be mapped into a completely flat histogram in the discrete case by the above method, it is very effective. Now suppose an image has L-level grayscale, then its mapping function from r to s is as formula (5), where k is the number of each grayscale level.

                           

     In order to facilitate understanding, the following exemplifies the whole process of histogram equalization.

    [Question 7 of 2013 Zhenti] Try to equalize the histogram of the following 8-level grayscale image, and give the equalized image and histogram.

                                                               

     Step 1: Count the frequency of occurrence of each gray level, and normalize the frequency.

     

    Step 2: Calculate the cumulative distribution of the original histogram

      

    Step 3: Expand and round

      

    Step 4: Mapping

    

       All the 0-> 1, 1-> 2, 2-> 3, 3-> 5, 4-> 6, 5-> 6, 6-> 7, 7-> 7 in the original picture can be completed Histogram equalization operation of the image, the results are as follows:

                                                               


Multiple histogram equalization


    If you perform histogram equalization on a histogram equalized image, the effect before and after processing is the same. From the operation process of histogram equalization, we can know that the spatial layout of an image will not change with the processing process. At this time, if the histogram of the image does not change, then the position and number of its gray levels will appear. No change, the result is that there is no difference between the two images before and after processing.

    For an image, the first histogram equalization uses the histogram of the original image, and then uses the newly generated histogram. It may be easier to understand the above invariance by using a continuous probability density function. The first histogram equalization maps the original odd-shaped probability density function to a uniform distribution, and then carries out on the basis of this uniform distribution. Histogram equalization, the result is also mapped to a uniform distribution, we know that the uniform distribution function is the same in the same interval. Change to discrete, that is, the histogram of the digital image. When the histogram is equalized for the first time, gray-scale merges and conversions will occur, and then the histogram equalization operation will not be performed on the newly generated histogram. In this case again, each gray level [the 7th question of the short answer question of the real question in 2013]


Cause of incomplete flatness


    ①

Published 28 original articles · Liked 34 · Visitors 20,000+

Guess you like

Origin blog.csdn.net/sinat_35907936/article/details/103758074