...
Manager
wiki

Histogram Equalization

4 June 2022
wiki
...

 

Introduction

Image enhancer ai is greatfull and amazing tool to improve the quality, size, brightness or contrast and the clearty of the input image.

After reading this text you will be familiar by histogram equalization conception.

...

what is Histogram

Histogram is a graphical representation of the intensity distribution of an image.

The intensity level usually ranges from 0 to 255. For a gray-scale image, there is only one histogram, whereas an RGB colored image will have three 2-D histograms; one for each color channel.

In other words histogram is a representation of frequency distribution. It is the basis for numerous spatial domain processing techniques.

In simple terms, it represents the number of pixels for each intensity value considered.

Histogram manipulation can be used for image enhancement and image improvement.

what is Histogram Equalization

Histogram Equalization is a computer image processing technique used to improve contrast in images.

In fact adjusts the contrast of input image by using its histogram.

It accomplishes this by effectively spreading out the most frequent intensity values, i.e. stretching out the intensity range of the image.

histogram equalization allows the image’s areas with lower contrast to gain a higher contrast.

...

GHE

Global histogram equalization (GHE) is very simple and fast, but its contrast enhancement power is low. Here the histogram of the whole input image is used to compute the histogram transformation

LHE

Local histogram equalization (LHE) can enhance the overall contrast more effectively.

Color Histogram Equalization

A color histogram of an image represents the number of pixels in each type of color component. Histogram equalization cannot be applied separately to the Red, Green and Blue components of the image as it leads to dramatic changes in the image’s color balance.

Adaptive Histogram Equalization

Adaptive Histogram Equalization differs from ordinary histogram equalization in the respect that the adaptive method computes several histograms, each corresponding to a distinct section of the image, and uses them to redistribute the lightness values of the image. It is therefore suitable for improving the local contrast and enhancing the definitions of edges in each region of an image.

Contrast Limited Adaptive Histogram Equalization

Contrast Limited AHE (CLAHE) differs from adaptive histogram equalization in its contrast limiting. In the case of CLAHE, the contrast limiting procedure is applied to each neighborhood from which a transformation function is derived. CLAHE was developed to prevent the over amplification of noise that adaptive histogram equalization can give rise to.

The Algorithm of histogram equalization

Compute the histogram of pixel values of the input image. The histogram places the value of each pixel 𝑓[𝑥,𝑦] into one of L uniformly-spaced buckets ℎ[𝑖]

Where 𝐿=2^8 and the image dimension is 𝑀×𝑁

Calculate the cumulative distribution function

Scale the input image using the cumulative distribution function to produce the output image.

Where CDFmin is the smallest non-zero value of the cumulative distribution function

Drawbacks of histogram equalization

One of the drawbacks of histogram equalization is that it can change the mean brightness of an image significantly as a consequence of histogram flattening and sometimes this is not a desirable property when preserving the original mean brightness of a given image is necessary. Bi-Histogram Equalization was proposed to overcome this problem. Overally this technique is the most applicable image processing method to improve image and image enhancement.

...

Python code

you can use the following code to view histogram of img (input image):

path = "...\flower.jpg" img = cv.imread(path)

hist,bins = np.histogram(img.flatten(),256,[0,256])

cdf = hist.cumsum()

cdf_normalized = cdf * float(hist.max()) / cdf.max()

plt.plot(cdf_normalized, color = 'b')

plt.hist(img.flatten(),256,[0,256], color = 'r')

plt.xlim([0,256])

plt.legend(('cdf','histogram'), loc = 'upper l

eft')

plt.show()

.equalizeHist() method to spreads out the pixel intensity values. We will assign the resulting image as the variable ‘equ’.

equ = cv.equalizeHist(img)

Now view the result image:

cv.imshow('equ.png',equ)

cv.waitKey(0)

cv.destroyAllWindows()

Anyway improve your photo and enjoy this image processing technology.

Install opencv enhance image by your pc or the laptop.