Lec15 Histogram Equalization
Lec15 Histogram Equalization
1
Normalized Histogram
Dividing each of histogram at gray level rk by
the total number of pixels in the image, n
p(rk) = nk / n
For k = 0,1,…,L-1
p(rk) gives an estimate of the probability of
occurrence of gray level rk
The sum of all components of a normalized
histogram is equal to 1
2
Histogram Processing
3
h(rk) or p(rk)
Example rk
Dark image
Components of
histogram are
concentrated on the
low side of the gray
scale.
Bright image
Components of
histogram are
concentrated on the
high side of the gray
scale.
4
Example
Low-contrast image
histogram is narrow
and centered toward
the middle of the
gray scale
High-contrast image
histogram covers broad
range of the gray scale
and the distribution of
pixels is not too far from
uniform, with very few
vertical lines being much
higher than the others
5
Histogram Equalization
6
Example
before after Histogram
equalization
7
Example No. of pixels
6
2 3 3 2 5
4 2 4 3 4
3 2 3 5 3
2
2 4 2 4
1
Gray level
4x4 image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,9]
histogram
8
Gray
0 1 2 3 4 5 6 7 8 9
Level(j)
No. of
0 0 6 5 4 1 0 0 0 0
pixels
k
n
j 0
j 0 0 6 11 15 16 16 16 16 16
k nj 6 11 15 16 16 16 16 16
s 0 0 / / / / / / / /
j 0 n
16 16 16 16 16 16 16 16
3.3 6.1 8.4
sx9 0 0 9 9 9 9 9
3 6 8
9
Example No. of pixels
6
3 6 6 3 5
8 3 8 6 4
6 3 6 9 3
2
3 8 3 8
1
Output image
0 1 2 3 4 5 6 7 8 9
Gray scale = [0,9] Gray level
Histogram equalization
10
Histogram Equalization
Approach
Fig: a) Original Image (b) Original Histogram
(c) Equalized Histogram (d) Enhanced Image
11
Image Enhancement by Histogram
Modification Technique
nk
p r ( rk ) 0 = rk = 1
---------- (10)
n k=0,1,…..L-1,
T h e d is c r e te fo r m o f e q u a liz a tio n te c h n iq u e s
g iv e n b y th e r e la tio n
k n
j
s k T (rk )
j 0 n 13
k 0= r k = 1
j0
p r (r j ) k= 0,1,… .L-1
------ (11)
r k = T -1 (s k ) 0= s k = 1,
14
Example: suppose that a 64*64, 8-levels image has the gray-
level distribution shown in table 1. The histogram of these
gray levels is shown in fig.3(a)
Table (1)
rk nk Pr(rk) = nk/n
r0 = 0 790 0.19
1023 0.25
r1=1/7
850 0.21
r2=2/7
656 0.16
r3=3/7
329 0.08
r4=4/7
245 0.06
r5=5/7
122 0.03
r6=6/7
r7=1 81 0.2
15
Figure No.3 Illustrated of the histogram –equalization method
(a) Original Histogram (b) Transformation function
(c) Equalization Histogram.
16
T h e tr a n s fo r m a tio n fu n c tio n is o b ta in e d b y u s in g
E q . (8 ). F o r in s ta n c e .
0
s o T ( ro ) j 0
p r (rj)
= p r(r 0)
= 0 .1 9
S im ila r ly ,
1
s 1 T ( r1 )
j 0
p r(rj)
= p r(r 0) + p r(r 1)
= 0 .4 4
A nd
s 2 = 0 .6 5 s 5 = 0 .9 5
` s 3 = 0 .8 1 s 6 = 0 .9 8
s 4 = 0 .8 9 s 7 = 1 .0 0 17
The in formation function has form shown in fig.3 (b).
Since only eight equally spaced levels are allowed in this case, each of
the transformed values must be assigned to its closest valid level. Thus
we have
s0=1/7 s4=6/7
s1=3/7 s5=1
s2=5/7 s6=1
s3=6/7 s7=1
It is noted that there only five distinct histogram-equalization gray
levels. Redefining the notation to take this into account yields the levels
s0=1/7 s4=1
s1=3/7
s2=5/7
s3=6/7
18
Since ro=0 was mapped to s o =1/7, there are 790 transformed
pixels with this new value . Also there are 1023 pixels with
value s1 =3/7and 850 pixels with value s2 = 5/7
How ever , since both levels r3and r4 were mapped to s3 = 6/7
, there are now 656+122=81=985 pixels with this new value.
Similarly, there are 245 + 122 +81 = 448 pixels with value
s4 =1 .Dividing these numbers by n= 4096 yield the histogram
shown in Fig.3(c) . Since a histogram is an approximation to a
probability density function, perfecting flat results are seldom
obtained when working with discrete levels.
19