02/05/2002 Histogram Processing 1
Image Enhancement:Histogram Processing
Reading: Chapter 3 (Spatial domain)
02/05/2002 Histogram Processing 2
Histogram Processing
� Histogram Equalization� Histogram Specification/Matching
02/05/2002 Histogram Processing 3
Histogram
p(rk)= nk/n
rk
rk Œ { 0, 1, 2, 3...., L−1}
nk : # pixels with gray level rk
n : # pixels in the image
02/05/2002 Histogram Processing 4
Histogram
02/05/2002 Histogram Processing 5
Figure 3.15: histograms
02/05/2002 Histogram Processing 6
Histogram Modification
r : Input gray level Œ [0, 1]s : Transformed gray level Œ [0, 1]
s = T (r) T : Transformation function
02/05/2002 Histogram Processing 7
Histogram Equalization
( i ) ( ) is single valued valued and monotonically increasing in ( ii ) for
[0, 1] [0Inverse transformation :
also satisfies ( i ) and ( ii )The gray levels in the image can be viewed as random variables takingvalues in the range [0,1].Let : p.d.f. of input level and let : p.d.f. of
(from ECE 140)
T
T rrT r r
T s r sT s
p r r p s s
s T r p s p r drds
r s
s rr T s
0 10 1 0 1
10 11
1
1
≤ ≤≤ ≤ ≤ ≤
→= ≤ ≤
= ∴ =
−
−
= −
( ), ]
( )( )
( ) ( )
( ) ; ( ) ( )( )
02/05/2002 Histogram Processing 8
Equalization (contd.)
We are interested in obtaining a transformation function T( )which transforms an arbitrary p.d.f. to an uniform distribution
pr(r) ps(s)
s
02/05/2002 Histogram Processing 9
Consider s
(Cumulative distribution function of r)
= = ≤ ≤
=
=LNM
OQP
=
∴ = ≡ ≤ ≤
z
z=
=
−
−
T r p w dw r
p s p r dr ds
dsdr
ddr
p w dw p r
p s p rp r
s
r
r
s r r T s
rr
r
s rr r T s
( ) ( )
( ) ( ) ;
( ) ( )
( ) ( )( )
( )
( )
0 1
1 1 0 1
0
0
1
1
02/05/2002 Histogram Processing 10
Equalization: Example
2
1r
pr(r)
p rr r
s T r w dw w w r r
r r s
r
rr
( )
( ) (2 ) (2 )
=− + ≤ ≤RST
= = − = − = −
∴ − + =
z
2 2 0 10
2 2
2 00
2
0
2
2
Else
02/05/2002 Histogram Processing 11
Equalization (example: contd.)
r s s
r T s s r
p s p r drds
r dds
s
r s
ss
r
s rr s
= + ± − = ± −
= = − − ∈
= = − + − −
= − + − − −FHG
IKJ
= − + − + +−
= ≤ ≤
−
= − −
−
2 4 42
1 1
1 1 1
2 2 1 1
2 2 12
1 1
2 2 1 2 12 1
1 0 1
1
1 1
1 2
( ) [0, ]
( ) ( ) ( ) ( )
( ) ( ) ( )
( )
/
as
02/05/2002 Histogram Processing 12
Equalized Histograms
02/05/2002 Histogram Processing 13
Fig 3.18: Transformation curves
02/05/2002 Histogram Processing 14
Equalization: Discrete Case
0
Number of levels
p r nn
r k L
L
s T r p r nn
r kk
k
k k r jj
j
k
j
k
( ) ; , ,...,
( ) ( )
= ≤ ≤ = −
→
= = ===∑∑
1 0 1 1
00
02/05/2002 Histogram Processing 15
Discrete Case: Example
64x64 image; 8 gray levels.
Notice that equalized histogram is notperfectly flat!
k r n nn S n
n p s
ssssssss
k kk
kj
j
k
s k=
→ →→ →→ →→ →→ →→ →→ →→ →
=∑
0
17 0
17
37 1
27
57 2
37
67 3
47
67 3
57 4
67 4
77 4
0 0 790 0 19 0 19 0 191 1023 0 25 0 0 252 850 0 21 0 65 0 213 656 0 16 0 81 0 244 329 0 08 0 89 0 245 245 0 06 0 95 1 0 116 122 0 03 0 98 1 0 117 81 0 02 1 0 1 0 11
( )
. . .. .44 .. . .. . .. . .. . .. . .. . .
02/05/2002 Histogram Processing 16
Equalization: Image Examples
Original, Equalized (64)Equalized (256)
02/05/2002 Histogram Processing 17
..and their histograms
Original, equalized (64 levels)Equalized (256 levels)
02/05/2002 Histogram Processing 18
Histogram specification
Suppose
Original histogram ; Desired histogram
Let and
But and are identical p.d.f.
s T r p w dw
p r p z
v G z p w dw z G v
s vz G v G s G T r
r
r
r z
z
z
= =
→ →
= = =
∴ = = =
z
z −
− − −
( ) ( )
( ) ( )
( ) ( ) ( )
( ) ( ) ( ( ))
0
0
1
1 1 1
02/05/2002 Histogram Processing 19
Question
� What happens when you apply equalization to an already equalized histogram� In the continuous case?� In the discrete case?
02/05/2002 Histogram Processing 20
Fig 3.19: Matching
02/05/2002 Histogram Processing 21
Matching: Summary
Steps:(1) Equalize the levels of original image(2) Specify the desired pz(z) and obtain G(z)(3) Apply z=G-1(s) to the levels s obtained in
step 1
02/05/2002 Histogram Processing 22
Matching: an example
z p z v G r n p zzzzz sz sz sz sz
k z k k k k z k 0 0 0
0 0 0 0 0 0 0.15 = 790 0.19 0.35 = 1023 0.25 0.65 = 850 0.21 0.85 = 985 0.24
17
37
57
67
( ) ( ) ( )
.
.
.
..
===== ↔= ↔= ↔= ↔=
0
11
7
22
7
33
7 0
44
7 1
55
7 2
66
7 3
7
0 000
0 150 20 30 2
1 015 4 1.0 = 1 448 0.11 ↔ s
02/05/2002 Histogram Processing 23
Histogram Matching: example
Original image(Jenolan caves,blue mountain,Sydney, Ausralia)
02/05/2002 Histogram Processing 24
Color to grayscale
I=imread(�sydney1.jpg);I1=rgb2gray(I);I1=imresize(I1,0.5);Imhist(I1);
02/05/2002 Histogram Processing 25
Desired & modified histograms
I2=histeq(I1,imhist(J));Imhist(I2);
Imhist(J)J=some image
02/05/2002 Histogram Processing 26
Histogram modified image
02/05/2002 Histogram Processing 27
Fig 3.20: Another example
02/05/2002 Histogram Processing 28
Fig 3.21
02/05/2002 Histogram Processing 29
Fig 3.22
Top Related