Haven’t written Blog for a long time…… Recently, I have learned a lot about image processing in my internship company, so I have a chance to sort out my study notes.

Histogram equalization

Histogram equalization is a method of adjusting contrast using image histogram in image processing field.

Adaptive Histogram Equalization (AHE)

1. A brief introduction

Adaptive Histogram Equalization (AHE) is a computer image processing technology used to improve image contrast. The difference with normal histogram equalization algorithms is that it calculates the histogram of a given area and uses these values to redistribute the brightness of the image to change the contrast of the image. Therefore, this method is more suitable for improving local contrast and enhancing image edges to obtain more details. The problem with AHE, however, is that while the contrast is enhanced, it also amplifies the Noise of the image. An improved method is CLAHE, which is histogram equalization that limits the contrast.

2. Algorithm description

First, histogram equalization (HE) HE is a very common histogram method. The basic idea is to determine a transformation function through the histogram of the gray distribution of the image, which is used to transform the gray scale of the image, so as to improve the image contrast. The transformation function is a cumulative distribution function.

Algorithm steps (1) calculate the gray histogram S (2) of the input image IMG for normalization processing, and calculate the normalized cumulative distribution density fHist (3) calculate the gray value mapping, and obtain the new histogram results

It can be seen that HE computes and processes the overall histogram. The processing effect of such method is ok for images with uniform gray distribution, but after processing histogram with peak, the contrast is too unnatural. AHE is based on this problem to reduce the scope of calculation from the whole to the local. That is, each pixel is equalized through the pixel histogram of a rectangular range around it in the same way as HE. Of course, in the image edge, pixels need special processing, which is solved by mirroring the image edge of the row pixel or column pixel. It is not appropriate to directly copy the pixels of the edge to expand. Because this leads to a field histogram with a sword edge.

Adaptive histogram Equalization with Contrast Limitation (CLAHE)

Unlike AHE, CLAHE has limits on contrast within each small area. This is achieved mainly by limiting the contrast enhancement of AHE.

1. Algorithm idea

The contrast magnification around the specified pixel value is mainly determined by the slope of the transform function. This slope is proportional to the slope of the cumulative histogram of the field. CLAHE limits the magnification by clipping the histogram with predefined thresholds before calculating the CDF. This limits the slant of the CDF, and therefore the slant of the transformation function


So instead of ignoring the upper part, CLAHE distributes it evenly across the rest.

2. To improve

In order to improve the calculation speed and eliminate the problems of block edge transition imbalance caused by block processing, interpolation method can be used. However, this is the concept of numerical analysis, so I did not understand…… for a long time A nice looking reference link here is adaptive histogram equalization with contrast limitation (CLAHE)

Update 7.25: After a discussion with a friend, I have figured out why interpolation can speed up the calculation.

First of all unary linear interpolation is more common, is usedInterpolate it inwardandThe line segment between. And then bivariate linearity is just adding a lambda, lambda

(Which is a quadratic form)

Now I can predict the pixel value of a point from the pixel value of four points, a very common four-point interpolation method. This has the advantage of eliminating the need to compute successive pixel values. It is equivalent to lowering the fine grid to the coarse grid and then reducing the computation.

For example, the original 100×100 scale, now only 50×50 scale, the remaining points will be interpolated. Therefore, in processing, we only need to do a few small-scale calculations, and then for the new point, if it is judged to be within a certain range, we will directly interpolate it with four points (or 6 or 8 points). Obviously, the computation speeds up.

reference

[1] Adaptive histogram equalization algorithm of limited contrast [2] Adaptive histogram equalization [3]Wikipedia: Adaptive histogram equalization