Histogram Equalization in Image Processing

Contents

1. Definition of Histogram Equalization

2. What are the steps to perform histogram equalization? 

3. How to generate the histogram equalized image of the given image?

1. Histogram Equalization in Image Processing, is a technique used to improve or enhance the contrast in an image. It can be achieved by the stretching out the intensity range of an image.  Histogram Linearization is also known as Histogram Equalization. It is used in manipulating

2. What are the steps to perform histogram equalization?

    i) Read the input image.
    ii) Find the running sum of the histogram values.
    iii) Normalize the values from step (ii) by dividing the total number of pixels.    

    iv)  Multiply the values from step (iii) by the maximum gray level value and round.

    v) Map the gray level values to the results from step (iv) using one to one correspondence. 

Example of histogram equalization. (a) The input image and (b) its... |  Download Scientific Diagram

Figure: Example of Histogram equalization


3. How to generate the histogram equalized image of the given image?

Consider the following image f(x,y), find the output image after histogram equalization.

Original Image= f(x,y)=

4

4

4

4

4

3

4

5

4

3

3

5

5

5

3

3

4

5

4

3

4

4

4

4

4

  

Highest gray level value in the given image is 5. 

And the total number of pixels in the given image is 25.

 

Gray Level

0

1

2

3

4

5

6

7

Number of pixels

0

0

0

6

14

5

0

0

  
          Figure(a): Histogram of the Original image


Gray Level

Number of pixels(n)

PDF= n/sum of pixels

CDF= Sk

Sk*7

Histogram Equalized Level

0

0

0

0

0*7=0

0

1

0

0

0+0 =0

0*7=0

0

2

0

0

0+0=0

0*7=0

0

3

6

6/25=0.24

0+0.24=0.24

0.24*7=1.68

2

4

14

14/25=0.56

0.24+0.56=0.8

0.8*7=5.6

6

5

5

5/25=0.2

0.8+0.2=1.0

1.0*7=7

7

6

0

0

1.0+0=1.0

1.0*7=7

7

7

0

0

1.0+0=1.0

1.0*7=7

7


Note: In above table PDF is Probability Distribution Function and CDF is cumulative Distribution Function.

Output image after histogram equalization=g(x,y)=

6

6

6

6

6

2

6

7

6

2

2

7

7

7

2

2

6

7

6

2

6

6

6

6

6

 

 

Figure(b):  Output image after histogram equalization. 


4. MATLAB program for histogram mapping and equalization.
clc;
clear all;
close all;
a = imread('Flower.jpg');
b = rgb2gray(a);
subplot(2,2,1);
imshow(b);

title('grayscale image of original rgb image');
c = im2double(b);
subplot(2,2,2);
imhist(c);

title('histogram mapping of grayscale original image');
d = histeq (c);
subplot(2,2,3);
imshow(d);

title('grayscale original image after histogram equalization');
subplot(2,2,4);
imhist(d);

title('histogram mapping of equalized grayscale original image');


OUTPUT:


Blog Written by, 

Prof. Mahendra Patil, 

Department of Computer Engineering, 

Atharva College of Engineering, Mumbai.









































4 comments:

  1. Thank you Sir for sharing this information. It is really very helpful and easy to understand.

    ReplyDelete
  2. Very good example on Histogram Equalization

    ReplyDelete

ads
Powered by Blogger.