0% found this document useful (0 votes)
7 views16 pages

Lecture 6

Histogram equalization is an approach to enhance images by transforming the image's grayscale values so that their histogram is uniform, resulting in increased contrast. It works by mapping the image's grayscale values to a new range based on their cumulative distribution function (CDF) so that each grayscale value in the output image is distributed uniformly. To implement it, the input image's histogram is computed and used to determine the CDF-based mapping to a discrete set of output grayscale values to produce a histogram-equalized image with improved contrast.

Uploaded by

jerkerprince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views16 pages

Lecture 6

Histogram equalization is an approach to enhance images by transforming the image's grayscale values so that their histogram is uniform, resulting in increased contrast. It works by mapping the image's grayscale values to a new range based on their cumulative distribution function (CDF) so that each grayscale value in the output image is distributed uniformly. To implement it, the input image's histogram is computed and used to determine the CDF-based mapping to a discrete set of output grayscale values to produce a histogram-equalized image with improved contrast.

Uploaded by

jerkerprince
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 16

ASET

Lecture6

1
Histogram Equalization ASET

• What is the histogram equalization?


The histogram equalization is an approach to enhance a given
image. The approach is to design a transformation T(.) such that
the gray values in the output is uniformly distributed in [0, 1].

Letus assume for the moment that the input image to be


enhanced has continuous gray values, with r = 0 representing
black and r = 1 representing white.

• We need to design a gray value transformation s = T(r), based


on the histogram of the input image, which will enhance the
image.

2
ASET

As before, we assume that:


(1) T(r) is a monotonically (Uniformly) increasing function for
0 r 1 (preserves order from black to white).
(2) T(r) maps [0,1] into [0,1] (preserves the range of allowed
Gray values).

3
ASET

Letus denote the inverse transformation by r = T -1(s) . We


assume that the inverse transformation also satisfies the above
two conditions.

Weconsider the gray values in the input image and output


image as random variables in the interval [0, 1].

Let
pin(r) and pout(s) denote the probability density of the
Gray values in the input and output images.

4
ASET

· If pin(r) and T(r) are known, and r = T -1(s) satisfies


condition 1, we can write (result from probability theory):

 dr 
pout ( s )   pin (r ) 
 ds  r T 1 ( s )

One way to enhance the image is to design a transformation


T(.) such that the gray values in the output is uniformly
distributed in [0, 1], i.e. pout (s) = 1, 0  s1

Interms of histograms, the output image will have all


gray values in “equal proportion” .

This technique is called histogram equalization.


5
ASET

Next we derive the gray values in the output is uniformly


distributed in [0, 1].
• Consider the transformation
r
s  T (r )   pin ( w)dw, 0  r 1
0

Note that this is the cumulative distribution function (CDF)


of pin (r) and satisfies the previous two conditions.

From the previous equation and using the fundamental


theorem of calculus,
ds
 pin (r )
dr

6
ASET

Therefore, the output histogram is given by

 1 
pout ( s )   pin (r )    1r T 1 ( s )  1, 0  s 1
 pin (r )  r T 1 ( s )

The output probability density function is uniform,


regardless of the input.
Thus, using a transformation function equal to the CDF of
input gray values r, we can obtain an image with uniform
gray values.
This usually results in an enhanced image, with an increase
in the dynamic range of pixel values.
7
ASET

How to implement histogram equalization?


Step 1:For images with discrete gray values, compute:
nk
pin (rk )  0  rk  1 0  k  L 1
n
L: Total number of gray levels
nk: Number of pixels with gray value rk
n: Total number of pixels in the image

Step 2: Based on CDF, compute the discrete version of the


previous transformation :
k
sk  T (rk )   pin (r j ) 0  k  L 1
j 0

8
ASET

Example:
Consideran 8-level 64 x 64 image with gray values (0, 1, …,7).
The normalized gray values are (0, 1/7, 2/7, …, 1). The
normalized histogram is given below:

The gray values in output are also (0, 1/7, 2/7, …, 1).
9
ASET

# pixels
Fraction
of #
pixels

Gray
value Normalized gray value

10
ASET
k

 Applying the transformation, sk  T (rk )   pin (rj ) we have


j 0

11
ASET

Notice that there are only five distinct gray levels --- (1/7,
3/7, 5/7, 6/7, 1) in the output image. We will re label them
as (s0, s1, …, s4 ).

12

ASET

• With this transformation, the output image will have


histogram

13
ASET

Histogram of output
image

# pixels

Gray values

Note that the histogram of output image is only approximately,


and not exactly, uniform. This should not be surprising, since there
is no result that claims uniformity in the discrete case. 14
Original image and its histogram
ASET

15
Histogram equalized image and its histogram ASET

16

You might also like