The English name of histogram equalization is histogram equalization.
Image Contrast enhancement can be divided into two types: direct contrast enhancement and indirect contrast enhancement. Histogram stretching and histogram equalization are two of the most common indirect contrast enhancement methods. Histogram stretching is to adjust the histogram by contrast stretching to "Expand" the difference between the foreground and the background gray level to enhance the contrast, this method can be implemented using a linear or non-linear method. histogram equalization is implemented by "Adjusting" the gray value by using the cumulative function to enhance the contrast.
The central idea of histogram equalization is to change the gray-scale histogram of the original image from a gray-scale interval in the comparison set to a uniform distribution within all gray-scale ranges. Histogram equalization refers to non-linear stretching of the image, and re-allocating the image pixel value, so that the number of pixels within a certain gray range is roughly the same. Histogram equalization is to change the histogram distribution of a given image to "even" distribution histogram distribution.
Disadvantages:
1) after the transformation, the gray level of the image is reduced, and some details are lost;
2) some images, such as histograms with peaks, do not naturally increase their contrast after processing.
Histogram equalization is a method that uses image histograms to adjust the contrast in image processing.
This method is usually used to increase the local contrast of many images, especially when the contrast of useful data is very close. In this way, the brightness can be better distributed on the histogram. This function can be used to enhance the local contrast without affecting the overall contrast. histogram equalization is implemented by effectively expanding the commonly used brightness.
This method is very useful for images with too bright or too dark backgrounds and prospects, this method, in particular, can bring better bone structure display in X-ray images and better details in photos of over-exposure or under-exposure. One of the main advantages of this method is that it is a fairly intuitive technique and reversible operation. If the equalization function is known, the original Histogram can be restored, and the amount of computing is not large. One disadvantage of this method is that it does not select the processed data. It may increase the contrast of background noise and reduce the contrast of useful signals.
The basic idea of histogram equalization is to transform the histogram of the original graph into a uniform distribution form, which increases the dynamic range of the pixel gray value so as to enhance the overall contrast of the image. If the gray scale of the original image (X, Y) is f, and the changed image is g, the image enhancement method can be expressed) the gray F ing at the position is G. The ing function for images in grayscale histogram equalization can be defined as: g = eq (f). This ing function is eq (f) two conditions must be met (L indicates the gray level of the image ):
(1) eq (f) is a single-valued single-incrementing function in the range of 0 ≤ F ≤ L-1. This is to ensure that the enhancement process does not disrupt the gray order of the original image, and the gray level of the original image remains in the black to white (or from white to black) after the transformation.
(2) For 0 ≤ F ≤ L-1 0 ≤ G ≤ L-1, this condition ensures the consistent gray value dynamic range before and after the transformation
.
Cumulative distribution function (CDF) can meet the above two conditions, and can be used to convert the distribution of the original image F to G uniform distribution. At this time, the histogram equalization ing function is:
GK = eq (FK) = (Ni/n) = PF (FI ),
(K = 0, 1, 2 ,......, L-1)
The sum range is 0 to K. According to this equation, the gray level of each pixel after histogram equalization can be obtained directly from the gray level of each pixel of the source image. In actual processing and transformation, statistical analysis is generally performed on the gray scale of the original image first, and the original histogram distribution is calculated, then, the gray-scale ing relationship between FK and GK is obtained based on the calculated cumulative histogram distribution. After repeat the preceding steps to obtain the ing between all gray levels of the source image and the gray level of the target image, perform grayscale conversion on each point of the source Image Based on the ing relationship to achieve histogram equalization of the source image.
For programming implementation, we do not need to call the MATLAB library function and implement it by ourselves. In this way, we can better understand the histogram equalization technology and improve programming capabilities.
Implementation Code (MatLab ):
% Histogram equalization I = imread('rice.png '); [height, width] = size (I); figuresubplot (221) imshow (I) % display original image subplot (222) imhist (I) % displays the original image histogram % for Pixel grayscale statistics; numpixel = zeros (1,256); % for counting the number of gray levels, a total of 256 gray levels for I = 1: height for j = 1: width numpixel (I, j) + 1) = numpixel (I, j) + 1) + 1; % add an endend % for the number of pixels corresponding to the gray value to calculate the gray distribution density probpixel = zeros (1,256); for I = probpixel (I) = numpixel (I) /(height * width * 1.0); end % calculates the cumulative histogram distribution cumupixel = zeros (1,256); for I = If I = 1 cumupixel (I) = probpixel (I); else cumupixel (I) = cumupixel (I-1) + probpixel (I); endend % the cumulative distribution is set to cumupixel = uint8 (255. * cumupixel + 0.5); % ing (equalization) for I = 1: height for j = 1: width I (I, j) = cumupixel (I, j); endendsubplot (223) imshow (I) % Show Original Image subplot (224) imhist (I) % Show Original Image Histogram
Running result: