Académique Documents
Professionnel Documents
Culture Documents
IMAGE ENHANCEMENT
Histogram Processing
by
Paresh Kamble
Histogram Processing
Histogram:
It is a plot of frequency of occurrence of an event.
freq. of
occurrence
event
Histogram Processing
Histogram of images provide a global description of their
appearance.
Enormous information is obtained.
It is a spatial domain technique.
Histogram of an image represents relative frequency of
occurrence of various gray levels.
Histogram can be plotted in two ways:
Histogram Processing
First Method:
X-axis has gray levels & Y-axis has No. of pixels in each gray
levels.
Gray Level
40
30
2
3
4
5
20
10
3
Gray Levels
Histogram Processing
Second Method:
X-axis has gray levels & Y-axis has probability of occurrence of
gray levels.
P(|ik) = nk/ n; where, |ik- gray level
nk no. of pixels in kth gray level
n total number of pixels in an image
Prob. Of Occurrence 1
Gray Level
0
1
2
3
4
5
6
P(nk)
0.4
0.2
0.1
0.15
0.1
0.03
0.02
1
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
Histogram Processing
Advantage of 2nd method: Maximum value plotted will always be 1.
Whi t e- 1 , Bl ack- 0 .
Great deal of information can be obtained just by looking at histogram.
Types of Histograms:
Histogram Processing
Advantage of 2nd method: Maximum value plotted will always be 1.
Whi t e- 1 , Bl ack- 0 .
Great deal of information can be obtained just by looking at histogram.
Types of Histograms:
Histogram Processing
The last graph represent the best image.
It is a high contrast image.
Our aim would be to transform the first 3 histograms into the 4th type.
In other words we try to increase the dynamic range of the image.
Histogram Stretching
1 ) Linear stretching:
Here, we don't alter the basic shape.
We use basic equation of a straight line having a slope.
(S m a x ^ m in )/ (^ m a x ~ m in )
Histogram Processing
S = T(r) = ((Smax - Smin)/(rmax - rmin))(r - rmin) + Smin
rmax
Histogram Processing
E x .1 ) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Histogram Processing
E x .1 ) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels
No. of Pixels
Soln:r,
. = 0
*,
'min
,i
s^max = 7'
(7/4)(r-2) = S
2
3
4
5
6
0
=0
7/4 =1.75 = 2
7/2 = 3.5 = 4
21/4 = 5.25 = 5
7
=7
Histogram Processing
E x .1 ) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels
No. of Pixels
50
60
50
20
10
Histogram Processing
Ex. 2) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 .
Histogram Processing
Ex. 2) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 .
Gray Levels
No. of Pixels
100
90
85
70
Histogram Equalization
o
Linear stretching is a good technique but not perfect since the shape
remains the same.
Histogram Equalization
Normal Histogram
nk
Equalized Histogram
nk
Li
Linearly Stretched Histogram
Histogram Equalization
o We have to search for a transform that converts any random histogram
into flat histogram,
o
S = T(r)
o We have to find T which produces equal values in each gray levels,
o The Transform should satisfy following 2 conditions:
(i)
(ii)
Histogram Equalization
These two conditions mean:
1 ) If T(r) is not single value:
Histogram Equalization
Big Drawback!
2) If condition (ii) is not satisfied then mapping will not be consistent with the
allowed range of pixel value.
Histogram Equalization
1^
(a)
Prob. Density (Original Image)
x
inv. Slope of transformation
Histogram Equalization
; 0<r< 1
diff. wrt. r
d s / d r = Pr(r)
Equating eqn(a) & eqn(b), we get
Ps(s) = [ l ] ; 0 < S < l
i.e.
Ps(s)= 1
--------- (b)
Histogram Equalization
Pr(r)
1
Ps(s)
Non-Uniform Function
>
>
0
I S
Uniform Function
Histogram Equalization
NOTE: If 'rV is total no. of pixels in an image, then PDF is given by:
Pr(rk) = nk/n;
In frequency domain,
S = T(r) = Pr(rk) dr
o
In discrete domain,
Sk = T(rk) =
I
k=0
Pr(rk)
(CDF)
Histogram Equalization
P ro b .1 ) Equalize the given histogram
No. of Pixels
790
1023
850
656
329
245
122
81
Histogram
Gray Levels
(rk)
0
No. of Pixels
k
790
(PDF)
Pr(rk) = nk/n
1023
0.25
830
0.21
656
0.16
329
0.08
245
0.06
122
0.03
81
0.02
n = 4096
0.19
Equalization
(CDF)
Sk =2 Pk(rk)
(L-l) Sk = 7 x Sk
Rounding
off
0.19
1.33
0.44
3.08
0.65
4.55
0.81
5.67
0.89
6.23
0.95
6.65
0.98
6.86
:4096
Hence Verified!!!
Histogram Equalization
Equalized Histogram
Gray Levels (S)
No. of Pixels
790
3
0
1023
4
0
850
985
Histogram Equalization
Prob. 2) Equalize the given histogram
Histogram Equalization
Prob. 3) Equalize the above histogram twice.
Histogram Equalization
Prob. 3) Equalize the above histogram twice.
Histogram Equalization
Prob.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0
12
13
no. of
pixels
1
0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15
no. of levels
Histogram Equalization
Prob.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0
2 |" 3
Histogram Equalization
Prob.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0
12
13
11
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
00)0
00 X
oox
OODC
1100
1101
1110
1111
01
01CX
010(
010C
10
100C
100C
100C
hoc
110(
11
lic x
Histogram Equalization
Prob.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
|
1 2
12
13
12
12
12
12
7
11
14
15
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
00 X
00 X
oox
00DC
1100
1101
1110
1111
01
01CX
010(
010C
10 )0
10D0
10 0
10
11 I ) 11 0 11 0
Setting lower order bit plane to zero.
11
Histogram Equalization
Prob.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
|
1 2
12
13
12
12
12
12
oooc
oox
OIOl
010(
100C
10
1101
HOC
7
11
14
15
-------------------------------------------------- >
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 no. of levels
Histogram Equalization
12
13
Q
Q
B
Prob. 2) What effect would setting to zero the higher order bit plane have on the
histogram of an image shown? Comment on the image.
Histogram Equalization
Prob. 3) Given below is the slope transformation & the image. Draw the frequency
tables for the original & the new image. Assume lmin=0, lmax = 7
Frequency Domain
2-D Discrete Fourier Transform & Its Inverse:
If f(x, y) is a digital image of size M X N then its Fourier Transform is given by:
F(u, v) = I J
f(x, y) e -j2n(ux/M+vy/
) -------------
x=0 y=0
-------- (2)
u=0 v=0
for x = 0 , 1 , 2, ....M -l
& y = 0 ,1 ,2 , , N-l
E q n .(1)& (2) constitute the 2-D discrete Fourier transform pair.
Frequency Domain
2-D convolution Theorem:
The expression of circular convolution is extended for 2-D is given below:
------- (3)
m=0 n=0
& y = 0 , 1 , 2 , N -l
F(u, v )x H (u , v)
------------(4)
and conversely
f(x, y) x h(x, y)
F(u, v)BH(u, v)
(5)
Frequency Domain
Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig.
below: y(p; q) = x ( m l , n l )U h(m2, n2)
2x2 (m, n)
3x3 (m; n)
Frequency Domain
Prob 4) Find the convolution of an image x(m, n) & h(m, n) shown in the fig.
below: y(p; q) = x ( m l , n l )U h(m2, n2)
0
-1
-1
4 ,
1 1
origin
0
-1
0
3x3 (m l, n l)
m l + m2 -1
3 + 2-1
4 columns
= n l + n2 -1
= 3 + 2-1
=4 rows
Frequency Domain
x(m, n)
1
-1
-1
-1
-1
h(m, -n)
h(-m/ -n)
>
Frequency Domain
h(-m; -n)
x(m, n)
0 - 1 1
1
-1
Frequency Domain
Frequency Domain
Frequency Domain
Frequency Domain
Frequency Domain
x(m, n)
1
-1
-1
-1
-1
V (2 ,-1)
h(2-m, -1-n)
-1
-1
-6
-1
- 1 1
1 1
Frequency Domain
h(-m, -n)
x(m / n)
0 - 1 1
- 1 1
- 1 4 - 1
1 1
0 - 1 0
y(m, n)
-1
-1
-2
-1
-6
-1
Frequency Domain
Homomorphic Filtering:
lllumination-Reflectance model for an image f(x, y) is given by:
f(x ,y ) = i(x ,y )r(x ,y )
---------- (1)
where, i(x, y) - illumination
r(x, y) reflectance
It is used to develop a frequency domain procedure for improving image
appearance b y :
(i) simultaneous intensity range compression and
(ii) contrast enhancement.
Eqn ( 1 ) cant be directly operated on the frequency components of
illumination & reflectance
This is because F[f(x, y)] t F[i(x, y)]F[r(x, y)]
However, if we define
z(x, y) = In f(x, y)
= ln i(x, y) + In r(x, y)
Frequency Domain
Then F{z(x, y)} = F{ln f(x, y)}
= F{ln i(x, y )}+ F{ln r(x, y)}
Or
Frequency Domain
Defining
r(x, y) = P 1{H(u/ v) F
(u, v)}
and
y) = PMHiu, v) Fr(u, v)}
We can express it in form s(x, y) = i'(x, y) + r'(x, y)
Finally, we reverse the process by taking the exponential of the filtered result
to form the output image:
g(x, y) = es(x' y>
= ei,(x' v) er/(x' y)
= i0(x,
y) r0(x, y)
Where, i0(x, y) & r0(x, y) are the illumination and reflectance components of
the output (processed) image.
Frequency Domain
g(x, y)
Compute the Gray level histogram of the output image obtained by enhancing
the input by histogram equalization technique.
[7m]
Q.9) What is Histogram Matching? Explain.
[5m]
0
6
[ [ [
Q.10) What are the advantages and disadvantages of median filter? Obtain
output image by applying 3 x 3 median filter on the following image. [8m]
123
1
78
2
281
3
417
639
5
6
7
1054 816 688
End of Unit-3