ch-2.2 histogram image processing .pptx

satyanarayana242612 300 views 69 slides Nov 05, 2024
Slide 1
Slide 1 of 69
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49
Slide 50
50
Slide 51
51
Slide 52
52
Slide 53
53
Slide 54
54
Slide 55
55
Slide 56
56
Slide 57
57
Slide 58
58
Slide 59
59
Slide 60
60
Slide 61
61
Slide 62
62
Slide 63
63
Slide 64
64
Slide 65
65
Slide 66
66
Slide 67
67
Slide 68
68
Slide 69
69

About This Presentation

histogram in dip


Slide Content

DIGITAL IMAGE PROCESSING IMAGE ENHANCEMENT Histogram Processing

Histogram Processing Histogram: It is a plot of frequency of occurrence of an event. freq. of occur r enc e 1 2 3 e v e n t

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 No. of Pixels (n k ) 40 1 20 2 10 3 15 4 10 5 3 6 2 n k 40 30 20 10 1 2 4 5 6 3 Gray Levels

Histogram Processing Second Method : X-axis has gray levels & Y-axis has probability of occurrence of gray levels. P(µ k ) = n k / n; where, µ k – gray level n k – no. of pixels in k th gray level n – total number of pixels in an image Prob. Of Occurrence 1 0.8 0.7 0.6 0.5 0.4 0.3 0.2 0.1 Gray Level No. of Pixels (n k ) P(µ k ) 40 0.4 1 20 0.2 2 10 0.1 3 15 0.15 4 10 0.1 5 3 0.03 6 2 0.02 n = 100 1 1 2 3 4 5 6 µ k

Histogram Processing Advantage of 2 nd method: Maximum value plotted will always be 1. White – 1, Black – 0. Great deal of information can be obtained just by looking at histogram. Types of Histograms: P(µ k ) P(µ k ) r k r k P(µ k ) P(µ k ) r k r k

Histogram Processing Advantage of 2 nd method: Maximum value plotted will always be 1. White – 1, Black – 0. Great deal of information can be obtained just by looking at histogram. Types of Histograms: P(µ k ) Dark Image P(µ k ) Bright Image r k r k P(µ k ) Low Contrast Image P(µ k ) Equalized Image r k r k

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 4 th 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 max - S min )/(r max - r min ) Where, Smax – max gray level of output image Smin – min gray level of output image rmax – max gray level of input image rmin – min gray level of input image 0 m i n m a x min m a x

Histogram Processing S = T(r) = ((S max - S min )/(r max - r min ))(r - r min ) + Smin S max S min r min r max

Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 1 2 3 4 5 6 7 No. of Pixels 50 60 50 20 10

Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 1 2 3 4 5 6 7 No. of Pixels 50 60 50 20 10 Sol n :- r min = 2; r max = 6; s min = 0; s max = 7; slope = ((s max – s min )/(r max - r min )) = ((7 - 0)/(6 - 2)) = 7 / 4 = 1.75. S = (7 / 4)(r - 2) + 0; S = (7 / 4)(r - 2) r (7 / 4)(r - 2) = S 2 0 = 3 7/4 = 1.75 = 2 4 7/2 = 3.5 = 4 5 21/4 = 5.25 = 5 6 7 = 7

Histogram Processing Ex. 1) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7]. Gray Levels 1 2 3 4 5 6 7 No. of Pixels 50 60 50 20 10 60 50 60 50 40 30 40 30 20 10 20 10 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7

Histogram Processing Ex. 2) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 . Gray Levels 1 2 3 4 5 6 7 No. of Pixels 100 90 85 70

Histogram Processing Ex. 2) Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 . Gray Levels 1 2 3 4 5 6 7 No. of Pixels 100 90 85 70 Dynamic range increases BUT No. of pixels at each gray level remains constant.

Histogram Equalization 2) Histogram Equalization: Linear stretching is a good technique but not perfect since the shape remains the same. Most of the time we need a flat histogram. It can’t be achieved by Histogram Stretching. Thus, new technique of Histogram Equalization came into use. Perfect image is one where all gray levels have equal number of pixels. Here, our objective is not only to spread the dynamic range but also to have equal pixels at all gray levels.

Histogram Equalization n k Normal Histogram r n k Equalized Histogram n k Linearly Stretched Histogram S S

Histogram Equalization o o We have to search for a transform that converts any random histogram into flat histogram. S = T(r) We have to find ‘T’ which produces equal values in each gray levels. The Transform should satisfy following 2 conditions: T(r) must be single value & monotonically increasing in the interval, 0 ≤ r ≤ 1. ≤ T(r) ≤ 1 for ≤ r ≤ 1 0 ≤ S ≤ 1 for ≤ r ≤ 1 Here, range of r is [0, 1] (Normalized range) instead of [0, 255].

Histogram Equalization These two conditions mean: 1) If T(r) is not single value: S T ( r) T (r) S S2 S1 S1 r1 r2 r r1 r2 r fig. (a) fig. (b)

Histogram Equalization In fig.(a) r1 & r2 are mapped as single gray level i.e. S1. Two different gray levels occupy same in modified image. Big Drawback! Hence, transformation has to be single value. This preserves order from black to white. A gray level transformation with single value and monotonically increasing is shown in fig.(b). 2) If condition (ii) is not satisfied then mapping will not be consistent with the allowed range of pixel value. S will go beyond the valid range.

Histogram Equalization Since, the Transformation is single value & monotonically increasing, the inverse Transformation exists. r = T -1 (S) ; ≤ S ≤ 1 Gray levels for continuous variables can be characterized by their probability density P r (r) & P s (S). From Probability theory, we know that, If P r (r) & P s (S) are known & if T -1 (S) satisfies condition (i) then the probability density of the transferred gray level is P s (S) = [P r (r). dr/ ds] r = -1 ----(a) T (S) Prob. Density (Transformed Image) = Prob. Density (Original Image) x inv. Slope of transformation

Histogram Equalization Now lets find a transform which would give us a flat histogram. Cumulative Density Function (CDF) is preferred. CDF is obtained by simply adding up all the PDF’s. S = T(r) ; 0 ≤ r ≤ 1 r S = § Pr(r) dr diff. wrt. r ds / dr = Pr(r) ---------(b) Equating eq n (a) & eq n (b), we get Ps(s) = *1+ ; 0 ≤ S ≤ 1 i.e. Ps(s) = 1

Histogram Equalization A bad Histogram becomes a flat histogram when we find the CDF. Pr(r) 1 Ps(s) 1 0 1 f Non-Uniform Function 0 1 S Uniform Function CDF Pr(r) dr

Histogram Equalization NOTE: If ‘n’ is total no. of pixels in an image, then PDF is given by: Pr(r k ) = n k / n; In frequency domain, r S = T(r) = § Pr(r k ) dr In discrete domain, (CD F ) r Sk = T(rk) = Pr(r k ) k=0

Histogram Equalization Prob. 1) Equalize the given histogram Gray Levels (r) 1 2 3 4 5 6 7 No. of Pixels 790 1023 850 656 329 245 122 81 nk 1000 900 800 700 600 500 400 300 200 100 1 2 3 4 5 6 7 r

Histogram Equalization Gray Levels ( r k ) No. of Pixels n k (PDF) Pr(rk) = nk/n (CDF) Sk = Pk(rk) (L-1) Sk = 7 x Sk R ound i n g off 790 0.19 0.19 1.33 1 1 1023 0.25 0.44 3.08 3 2 830 0.21 0.65 4.55 5 3 656 0.16 0.81 5.67 6 4 329 0.08 0.89 6.23 6 5 245 0.06 0.95 6.65 7 6 122 0.03 0.98 6.86 7 7 81 0.02 1 7 7 n = 4096 1 Equating Gray Levels to No. of Pixels: 0 -> 1 -> 790 2 -> 3 -> 1023 4 -> 5 -> 850 6 -> 985 7 -> 448 Total : 4096 Hence Verified!!!

Histogram Equalization Equalized Histogram: Gray Levels (S) 1 2 3 4 5 6 7 No. of Pixels 790 1023 850 985 448 Total: 4096 nk 1000 900 800 700 600 500 400 300 200 100 1 2 3 4 5 6 7 r

Histogram Equalization Prob. 2) Equalize the given histogram Gray Levels (r) 1 2 3 4 5 6 7 No. of Pixels 100 90 50 20 nk 100 90 80 70 60 50 40 30 20 10 1 2 3 4 5 6 7 r

Histogram Equalization Prob. 3) Equalize the above histogram twice. Gray Levels (r) 1 2 3 4 5 6 7 No. of Pixels 100 90 50 20 nk 100 90 80 70 60 50 40 30 20 10 1 2 3 4 5 6 7 r

Histogram Equalization Prob. 3) Equalize the above histogram twice. Gray Levels (r) 1 2 3 No. of Pixels 70 20 7 3 nk 100 90 80 70 60 50 40 30 20 10 1 2 3 r

Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? no. of p i x e l s 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11 12 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? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111

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 3 4 5 6 7 8 9 10 11 12 13 14 15 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 00 00 00 00 00 00 00 00 01 00 01 00 01 00 01 00 10 00 10 00 10 00 10 00 11 00 11 00 11 00 11 00 Setting lower order bit plane to zero.

Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 4 4 4 4 8 8 8 8 12 12 12 12 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 00 00 00 00 00 00 00 00 01 00 01 00 01 00 01 00 10 00 10 00 10 00 10 00 11 00 11 00 11 00 11 00 Setting lower order bit plane to zero.

Histogram Equalization Prob. 1) What effect would setting to zero the lower order bit plane have on the histogram of an image shown? 4 4 4 4 8 8 8 8 12 12 12 12 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 00 00 00 00 00 00 00 00 01 00 01 00 01 00 01 00 10 00 10 00 10 00 10 00 11 00 11 00 11 00 11 00 4 no. of pixels 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 no. of levels

Histogram Equalization 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. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Histogram Equalization Prob. 3) Given below is the slope transformation & the image. Draw the frequency tables for the original & the new image. Assume I min =0, I max = 7 I I max 2 3 4 2 5 5 2 4 3 6 3 5 6 3 5 5 I min m min m max µ

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: M-1 N-1 f(x, y) e -j2 π (ux/M + vy/N) F(u, v) = -----------(1) x=0 y=0 for u = 0, 1, 2, ……., M - 1 & v = 0, 1, 2, …….., N -1. Given the transform F(u, v), we can obtain f(x, y) by using Inverse discrete Fourier Transform (IDFT): ------------(2) M-1 N-1 f(x, y) = (1/MN) F(u, v) e j2 π (ux/M + vy/N) u=0 v=0 for x = 0, 1, 2, ….M - 1 & y = 0, 1, 2, ….., N -1 Eqn. (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: M-1 N-1 f(x, y)*h(x, y) = f(m, n)h(x-m, y-n) -----------(3) m=0 n=0 for x = 0, 1, 2, ….M - 1 & y = 0, 1, 2, …..N -1 The 2-D convolution theorem is given by the expressions f(x, y) ¤ h(x, y) F(u, v) x H(u, v) --------------(4) and conversely f(x, y) x h(x, y) F(u, v) ¤ H(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(m1, n1) ¤ h(m2, n2) 1 1 1 -1 2x2 (m, n) - 1 1 - 1 4 - 1 - 1 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(m1, n1) ¤ h(m2, n2) 1 1 1 -1 origin 2x2 (m2, n2) - 1 1 - 1 4 - 1 - 1 3x3 (m1, n1) p = m1 + m2 -1 = 3 + 2 -1 = 4 columns q = n1 + n2 -1 = 3 + 2 -1 = 4 rows Resultant image dimension is 4x4.

Frequency Domain - 1 x(m, n) 1 1 h(m, n) 1 - 1 4 -1 1 -1 - 1 1 h(m, -n) 1 h(-m, -n) - 1 1 - 1 1 1 1

Frequency Domain - 1 x(m, n) 1 h(-m, -n) - 1 4 -1 - 1 1 - 1 1 1 y(0, 0) 4

Frequency Domain - 1 x(m, n) 1 h(1-m, -n) - 1 4 -1 - 1 1 - 1 1 1 y(1, 0) 4 - 6

Frequency Domain - 1 x(m, n) 1 h(2-m, -n) - 1 4 -1 - 1 1 - 1 1 1 4 - 6 1 y(2, 0)

Frequency Domain x(m, n) h(3-m, -n) - 1 1 - 1 4 -1 - 1 1 - 1 1 1 y(3, 0) 4 -6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-m, 1-n) - 1 4 -1 1 1 - 1 y(0, 1) 2 4 - 6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-m, 2-n) - 1 4 -1 1 1 - 1 - 1 2 4 - 6 1 y(0, 2)

Frequency Domain - 1 x(m, n) 1 h(1-m, 1-n) - 1 4 -1 - 1 1 - 1 1 1 y(1, 1) -1 2 5 4 - 6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(1-m, 2-n) - 1 4 -1 1 1 - 1 y(1, 2) -1 2 5 4 -6 1

Frequency Domain - 1 x(m, n) 1 h(2-m, 1-n) - 1 4 -1 - 1 1 - 1 1 1 y(2, 1) -1 2 5 -2 4 -6 1

Frequency Domain - 1 x(m, n) 1 -1 h(2-m, 2-n) 1 - 1 4 -1 1 1 - 1 y(2, 2) -1 1 2 5 -2 4 -6 1

Frequency Domain - 1 x(m, n) 1 -1 1 h(-1-m, -n) - 1 4 -1 1 1 - 1 y(-1, 0) - 1 1 2 5 -2 -1 4 -6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-1-m, 1-n) - 1 4 -1 1 1 - 1 y(-1, 1) - 1 1 -1 2 5 -2 -1 4 -6 1

Frequency Domain h(-1-m, 2-n) x(m, n) -1 1 - 1 1 - 1 4 - 1 1 1 - 1 0 0 y(-1, 2) - 1 1 - 1 2 5 -2 - 1 4 -6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-1-m, -1-n) - 1 4 -1 1 1 - 1 y(-1, -1) -1 1 -1 2 5 - 2 -1 4 -6 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-m, -1-n) - 1 4 -1 1 1 - 1 y(0, -1) -1 1 - 1 2 5 -2 - 1 4 -6 1 -1

Frequency Domain - 1 x(m, n) 1 -1 1 h(1-m, -1-n) - 1 4 -1 1 1 - 1 y(1, -1) -1 1 - 1 2 5 -2 - 1 4 -6 1 -1 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(2-m, -1-n) - 1 4 -1 1 1 - 1 y(2, -1) -1 1 - 1 2 5 -2 - 1 4 -6 1 -1 1

Frequency Domain - 1 x(m, n) 1 - 1 1 h(-m, -n) - 1 4 -1 1 1 - 1 y(m, n) -1 1 - 1 2 5 -2 - 1 4 -6 1 -1 1

Frequency Domain Homomorphic Filtering: Illumination-Reflectance model for an image f(x, y) is given by: ------------(1) f(x, y) = i(x, y)r(x, y) where, i(x, y) – illumination r(x, y) – reflectance It is used to develop a frequency domain procedure for improving image appearance by : simultaneous intensity range compression and contrast enhancement. Eqn (1) cant be directly operated on the frequency components of illumination & reflectance This is because F*f(x, y)+ ≠ F* i(x, y)]F[r(x, y)] However, if we define z(x, y) = In f(x, y) = ln i(x, y) + ln 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 Z(u, v) = F i (u, v) + F r (u, v) Where F i (u, v) & F r (u, v) are FT of ln i(x, y) & r(x, y) resp. We can filter Z(u, v) by using a filter H(u, v) so that S(u, v) = H(u, v)Z(u, v) = H(u, v) F i (u, v) + H(u, v) F r (u, v) Filtered image in spatial domain is s(x, y) = F -1 {S(u, v)} = F -1 {H(u, v) F i (u, v)} + F -1 {H(u, v) F r (u, v)}

Frequency Domain Defining i ’(x, y) = F -1 {H(u, v) F i (u, v)} and r’(x, y) = F -1 {H(u, v) F r (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) = e s(x, y) = e i ’(x, y) e r ’(x, y) = i (x, y) r (x, y) Where, i (x, y) & r (x, y) are the illumination and reflectance components of the output (processed) image.

Frequency Domain f(x, y) g(x, y) This method is based on special case of a class of systems known as Homomorphic systems. ln DFT H(u, v) (DFT) -1 exp

Question Bank of Unit-3 Explain Histogram Processing? Why an ideal LPF not suitable for smoothing operation? Explain how the Gaussian LPF overcomes the drawback of ideal LPF. Write in short about Minimum Mean Square Error (Wiener) filtering. Suppose F(u, v) is a 2D Fourier transform of an image f(x, y) and a new function G(u, v) is obtained as G(u, v) = f(u/2, v/2). What would be the image g(x, y) after taking the Inverse Fourier transform of G(u, v)? Write a short note on Histogram Equalization. Q.6) Write a short note on Bit Plane Slicing. Q.7) Write a short note on Order Statistics Filter.

Question Bank of Unit-3 Q.8) The Gray level histogram of an image is given below: Gray Level 1 2 3 4 5 6 7 Frequency of occurrence 400 700 1350 2500 3000 1500 550 Compute the Gray level histogram of the output image obtained by enhancing the input by histogram equalization technique. [7m] What is Histogram Matching? Explain. [5m] What are the advantages and disadvantages of median filter? Obtain output image by applying 3 x 3 median filter on the following image. [8m] [ 2 4 15 0] [ 3 5 2 6] [11 0 2 10] [ 6 16 0 2]

Question Bank of Unit-3 Write a short note on different Gradient filters. Explain the following terms in significant details in reference to image enhancement in spatial domain: Contrast Stretching Histogram Equalization Bit Plane Slicing The Laplacian Explain Homomorphic filtering in frequency domain. [5m] Q.14) The gray level histogram of an image is given below: Compute the gray histogram of the output image obtained by enhancing the input by the histogram equalization technique. [9m] Gray Level 1 2 3 4 5 6 7 Freq. of Occurrence 123 78 281 417 639 1054 816 688

Question Bank of Unit-3 Explain the principle objective of image enhancement process in spatial domain process. Explain image subtraction, image averaging and image smoothing through smoothing linear filter. A short note on Median Filtering.

End of Unit-3
Tags