Professional Documents
Culture Documents
Lesing 3
Lesing 3
3 Histogram Processing Histogram h(rk ) = nk rk : kth gray level nk : number of pixels of gray level rk Normalization discrete PDF p(rk ) = nk /n n: total number of pixels
L1 X k=0
p(rk ) = 1
Lecture 3 (page 2)
Lecture 3 (page 3)
First consider continuous functions and transformations of the form s = T (r), r [0, 1] and assume that (a) T (r) single-valued, monot. increasing for r [0, 1] (b) T (r) [0, 1] for r [0, 1] Inverse transformation r = T 1(s), s [0, 1] Why?
3.3 Histogram Processing View gray levels as random variables pr (r): continuous PDF of r ps(s): continuous PDF of s If T 1(s) satises condition (a) then
Lecture 3 (page 4)
r 0
pr (w) dw
RHS is the cumulative distribution function (CDF) of r, and satises conditions (a) and (b). From Leibnizs rule... ds dT (r) = dr dr d Z r = pr (w) dw dr 0 = pr (r) dr ps(s) = pr (r) ds 1 = pr (r) pr (r) = 1, s [0, 1]
Lecture 3 (page 5)
r 0
r 0
pr (w) dw
pr (rj )
nj , k = 0, 1, 2, . . . , L 1 = j=0 n and is called histogram equalization NB: This will not produce a uniform histogram, but will tend to spread the histogram of the input image Advantages: Gray-level values cover entire scale (contrast enhancement) Fully automatic
Lecture 3 (page 6)
Lecture 3 (page 7)
Lecture 3 (page 8)
3.3.2 Histogram Matching (Specication) Some applications: hist. equalization not best approach So, generate processed image with specied histogram Development of the method Again consider continuous gray levels r and z... pr (r): continuous PDF for input image Let s be a random variable where s = T (r) =
Z
r 0
pr (w) dw
and dene z as a random variable where G(z) = thus G(z) = T (r) and z = G1(s) = G1 [ T (r) ]
Z
z 0
pz (t) dt = s,
Lecture 3 (page 9)
Procedure for continuous formulation (1) Obtain T (r) (2) Obtain G(z) (3) Obtain G1 (4) Pixels of input image T G1 Pixels of output image Seldom possible to obtain analytical expressions for T (r) and G1 Easier for discrete case, but only approximation for desired histogram Discrete formulation Recall histogram equalization... sk = T (rk ) = =
k X j=0 k X
pr (rj )
nj , k = 0, 1, 2, . . . , L 1 j=0 n
pz (zi) = sk , k = 0, 1, 2, . . . , L 1
j=0
pr (rj )
nj , k = 0, 1, 2, . . . , L 1 j=0 n
k X
vk = G(zk ) =
i=0
pz (zi) = sk , k = 0, 1, 2, . . . , L 1
z0 z1 . . zL1
G s0 = v0 G s1 = v1 . . . . G sL1 = vL1
(1) Obtain histogram of given image; (2) Precompute: rk sk ; (3) Obtain G from given pz (z) (4) Precompute: sk zk . Use iterative scheme... Let zk = z for each k, where z is the smallest integer in the interval [0, L 1] so that (G() sk ) 0, k = 0, 1, 2, . . . , L 1. z For k = k +1, start with z = zk and incr. in integer values (5) For each pixel, use (2) and (4): rk sk zk NB: None of the values of pz (zi) can be zero. Why?
Previous methods (3.3.1 and 3.3.2) were global Dene square or rectangular neighbourhood (mask) and move the center from pixel to pixel For each neighbourhood... Calculate histogram of the points in the neighbourhood Obtain histogram equalization/specication function Map gray level of pixel centered in neighbourhood Can use new pixel values and previous histogram to calculate next histogram Example 3.5: Enhancement using local histograms
3.3.4 Use of Hist. Statistics for Image Enhancement The nth moment of r (discrete) about its mean is dened as n(r) =
L1 X i=0
(ri m)2p(ri)
Mean: measure of average gray level Variance: measure of average contrast Let (x, y) be the coordinates of a pixel in an image, and Sxy denote a subimage centered at (x, y): mSxy =
2 Sxy (s,t)Sxy
X
rs,tp(rs,t)
(s,t)Sxy
g(x, y) =
E f (x, y) if mSxy [0, k0MG] AND Sxy [k1DG, k2DG] f (x, y) otherwise
Example 3.6: Enhancement based on local statistics E = 4.0; k0 = 0.4; k1 = 0.02; k2 = 0.4; (33) local region