Date post: | 22-Dec-2015 |
Category: |
Documents |
Upload: | adam-irwansyah-fauzi |
View: | 30 times |
Download: | 4 times |
Histogram ProcessingHistogram:
It is a plot of frequency of occurrence of an event.
freq. of occurrence
0 1 2 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
Gray Level No. of Pixels (n.
□ First Method:
□ X-axis has gray levels & Y-axis has No. of pixels in each gray levels.
40
30
20
10
0 2 3Gray Levels
23456
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 No. of Pixels (nk) P(nk)0.80.7
0 40 0.4 0.61 20 0.2 0.52 10 0.1 0.43 15 0.15 0.34 10 0.1 0.25 3 0.03 0.16 2 0.02
n = 100 1
Histogram Processing□ Advantage of 2nd method: Maximum value plotted will always be 1.□ Whi te- 1 , Black- 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 te- 1 , Black- 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 Stretching1 ) Linear stretching:□ Here, we don't alter the basic shape.□ We use basic equation of a straight line having a slope.
(Sm ax ■ ^ m in )/ (^ m ax ~ 「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
Histogram ProcessingE x .1 )Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Histogram ProcessingE x .1 )Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 [0, 7].
Gray Levels
No. of PixelsSoln:- r, ; . = 0 * s = 7''min リ, ^max , i
slope = ((smax - smin)/(rmax - rmin)) = ((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 = 03 7/4 =1.75 = 24 7/2 = 3.5 =45 21/4 = 5.25 = 56 7 = 7
Histogram ProcessingE x .1 )Perform Histogram Stretching so that the new image has a dynamic range of 0 to 7 [0, 7].
Gray Levels ■ 1 2
No. of Pixels 50 0 60
4 5 6 7
50 20 0 10
Histogram ProcessingEx. 2) Perform Histogram Stretching so that the new image has a dynamic
range of 0 to 7 .
Histogram ProcessingEx. 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 0 90 ■ 0 85 0 70
Dynamic range increasesBUT
No. of pixels at each gray level remains constant.
Histogram Equalization
o Linear stretching is a good technique but not perfect since the shape remains the same.
o Most of the time we need a flat histogram.
o It can't be achieved by Histogram Stretching.
o Thus, new technique of Histogram Equalization came into use.
o Perfect image is one where all gray levels have equal number of pixels.
o Here, our objective is not only to spread the dynamic range but also to have equal pixels at all gray levels.
Histogram Equalization
Normal Histogram
t ノnk Equalized Histogram nk LiLinearly Stretched Histogram
S S
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) T(r) must be single value & monotonically increasing in the interval, 0 < r < l .
(ii) 0 < T ( r ) < 1 for 0 < r< 10 < S < 1 for 0 < r < 1
Here, range of r is [0 ,1 ] (Normalized range) instead of [0, 255].
Histogram Equalization□ In fig.(a) r l & r2 are mapped as single gray level i.e. S I.
□ 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-^S) ; 0 < S < 1
□ Gray levels for continuous variables can be characterized by their probability density Pr(r) & Ps(S).
□ From Probability theory, we know that,□ If Pr(r) & Ps(S) are known & if T_1(S) satisfies condition (i) then the
probability density of the transferred gray level is
Ps(S) = [Pr(0. d r/ d s ]「イ 1̂ — (a)
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)
S = § Pr(r) dr ; 0 < r < 1o
diff. wrt. r
d s / d r = Pr(r) --------- (b)
Equating eqn(a) & eqn(b), we getPs(s) = [ l ] ; 0 < S < l
i.e. Ps(s)= 1
Histogram Equalization
□ A bad Histogram becomes a flat histogram when we find the CDF.
Pr(r)1
Ps(s)
—— > —— >
Non-Uniform Function0 I SUniform 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) dro
In discrete domain,
Sk = T(rk) = I Pr(rk) (CDF)k=0
Prob.1 ) Equalize the given histogram
Histogram Equalization
Gray Levels (r) D 1 2 3 4 5 6 7
No. of Pixels 790 1023 850 656 329 245 122 81
HistogramGray Levels
(rk)No. of Pixels
门 k(PDF)
Pr(rk) = nk/n
0 790 0.191 1023 0.25
2 830 0.213 656 0.16
4 329 0.085 245 0.06
6 122 0.03
7 81 0.02n = 4096 1
Equating Gray Levels to No. of Pixels: 0 -> 0 4 -> 01-> 790 5 -> 8502 -> 0 6 -> 9853 -> 1023 7 -> 448 Tota
Equalization(CDF)
Sk =2 Pk(rk)(L-l) Sk = 7 x Sk Rounding
off
0.19 1.33 10.44 3.08 3
0.65 4.55 50.81 5.67 6
0.89 6.23 60.95 6.65 7
0.98 6.86 7
1 7 7
:4096 Hence Verified!!!
Histogram EqualizationEqualized Histogram
Gray Levels (S) ■ 12 3 4 5 6
No. of Pixels 0 790 0 1023 0 850 985
Histogram EqualizationProb.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 1
4 5
8 9
12 13
■no. of pixels
1
0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15no. of levels
Prob.1 )What effect would setting to zero the lower order bit plane have on the histogram of an image shown?
0 1 2 |" 3
4 5 6 7
Histogram Equalization
Histogram EqualizationProb.1 )What effect would setting to zero the lower order bit plane have on the
histogram of an image shown?
0 1
4 5
8 9
12 13
11 0000 0001 0010 0011
0100 0101 0110 0111
1000 1001 1010 1011
1100 1101 1110 1111
00)0 00 X o o x OODC
01 01CX 010( 010C
10 100C 100C 100C
h o c 110( 11 lic x
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?
| | | | 0 0 0 0
0 1 2
4 5 6 7
8 9 11
12 13 14 15
0000 0001 0010 0011
0100 0101 0110 0111
1000 1001 1010 1011
1100 1101 1110 1111
12 12 12 12
A00 X 00 X oox 00DC
01 01CX 010( 010C
10 )0 10D0 10 0 10
11 I ) 11 0 11 0 11
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?
| | | | 0 0 0 0
0 1 2
4 5 6 7
8 9 11
12 13 14 1512 12 12 12
-------------------------------------------------- >
0 1 2 3 4 5 6 7 8 9 10 1112 13 14 15 no. of levels
oooc oox
OIOl 010(
100C 10
1101 HOC
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.
■BQQ
0 1
4 5
8 9
12 13
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
B 3 4 2
5 5 2 4
3 6 3 5
6 3 5 5
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/ N ) -------------⑴
x=0 y=0
for u = 0 ,1 ,2 , •••••••, M-l & v = 0 ,1 ,2t ......... , N-l.
Given the transform F(u, v), we can obtain f(x, y) by using Inverse discrete Fourier Transform (IDFT):
f(x,y) = (l/MN) I I F(u, v}eJ2n(ux/M + vv/N> --------(2)u=0 v=0
for x = 0 ,1 ,2, ....M -l & y = 0 ,1 ,2 , •••••, N-l 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:
f(x, y)*h(x; y) = I I f(m, n)h(x-m, y-n) ------- (3)m=0 n=0
forx = 0; 1,2, ....M-l & y = 0 ,1 ,2 , ••…N-l
The 2-D convolution theorem is given by the expressions
f(x, y) n h(x, y) F(u, v )xH (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)
3x3 (m; n)
2x2 (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
-1 4 ,ぐ ユ ヘ
0 -1 0、origin
3x3 (m l, n l)
1 1
2x2 (m2, n2)
m l + m2 -1
3 + 2-14 columns
=n l + n2 -1 = 3 + 2-1 =4 rows
Resultant image dimension is 4x4.
Frequency Domain
x(m, n) h(2-m, -1-n)0 -1 1 0 - 1 1
-1 4 -1 0 1 1
0 -1 0
V(2 ,-1) 0 -1 0
•1 2 5
-1 4 -6
0 -1 1
Frequency Domain
x(m/ n)0 - 1 1 - 1 1
- 1 4 - 1 1 1
0 - 1 0
y(m, n) 0 -1 0 1
-1 2 5 -2
-1 4 -6 1
0 -1 1 0
h(-m, -n)
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{lni(x, y)}+F{ln r(x, y)}
Or
Z(u, v) = Fj(u, v) + Fr(u, v)
Where Fj(u, v) & Fr(u, v) are FT of In 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) Fj(u, v) + H(u, v) Fr(u, v)
Filtered image in spatial domain is s(x, y) = F'MSlu, v)}
= F-HHlu, v) F ju , v)} + PMHlu, v) Fr(u, v)}
Frequency Domain
Definingr(x, y) = P 1{H(u/ v) F丨(u, v)}
andy) = 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
This method is based on special case of a class of systems known as Homomorphic systems.
g(x, y)
Question Bank of Unit-3Q .l) Explain Histogram Processing?
Q.2) Why an ideal LPF not suitable for smoothing operation? Explain how the Gaussian LPF overcomes the drawback of ideal LPF.
Q.3) Write in short about Minimum Mean Square Error (Wiener) filtering.
Q.4) 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)?
Q.5) 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:
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]
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]
0
6
0
2
2
3
L
6
[
[
[
[
Q .l l ) Write a short note on different Gradient filters.
Q.12) Explain the following terms in significant details in reference to image enhancement in spatial domain:(i) Contrast Stretching(ii) Histogram Equalization(iii) Bit Plane Slicing(iv) The Laplacian
Q.13) Explain Homomorphic filtering in frequency domain. [5m]
Question Bank of Unit-3
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 ■ 5 6 7Freq. of Occurrence 123 78 281 417 639 1054 816 688
Question Bank of Unit-3Q.15) Explain the principle objective of image enhancement process in spatial
domain process.
Q.16) Explain image subtraction, image averaging and image smoothing through smoothing linear filter.
Q.17) A short note on Median Filtering.