Example 1: Solution 1
Example 1: Solution 1
Example 1: Solution 1
Mohammad Alshamri
Example 1
What is the intensity resolution of a camera with 65536?
Solution 1
Example 2
How many colors a given camera can support if it has 24-bits intensity resolution?
Solution 2
Example 3
What are the values of spatial coordinates and 120 56 234
𝑓(𝑥, 𝑦) = [ 76 45 20 ]
intensity value of 𝑓(2,3)?
45 98 130
Solution 3
Example 4
What is the intensity value of a given pixel having an illumination of 231 incident on a
stainless steel?
Solution 4
Example 5
What is size of an image in MB having 640 × 520 pixels? Each pixel is represented by
16 bits.
Solution 5
𝑘𝑁𝑝 16 × 640 × 520
𝐼𝑠 = = = 634.76 MB
8 × 210 8 × 220
Example 6
List the conversion steps of analog image to digital one?
Solution 6
Example 7
What is the effect of:
• Reducing the number of pixels with a constant pixel size.
• Reducing the color depth (intensity resolution).
• Reducing the spatial resolution.
Solution 7
Example 8
Classify the following images
(a) (b)
(c) (d)
Solution 8
Example 9
What are the colors of the following codes in an RGB colormap? Resonate your answer.
(a) [1 0 0] (d) [0 0 0]
(b) [1 1 1] (e) [0 1 0]
(c) [0 0 1]
Solution 9
Example 10
Find 𝑁4 (3,4), and 𝑁𝐷 (3,4) for the following image?
3 211 111 210 23
60 200 255 230 122
𝑓(𝑥, 𝑦) = 28 68 89 𝟏𝟎𝟗 211
11 145 90 50 43
[33 38 57 222 54 ]
Solution 10
Example 11
Assume 𝑉 = {43,50,109,211, 255}. Which pixels have 4-adjacency with 𝑝 = 〈3,4〉?
Solution 11
The conditions for 4- adjacency between 𝑝 and 𝑞 are
𝑓(𝑝) ∈ 𝑉 Yes Hence 𝑞 = 〈3,5〉 and 𝑞 = 〈4,4〉 satisfy the three
𝑓(𝑞) ∈ 𝑉 Yes conditions and have 4-adjacency with 𝑝 = 〈3,4〉.
𝑞 ∈ 𝑁4 (𝑝) Yes
Example 12
Assume 𝑉 = {43,50,109,211,255}. Which pixels have 8-adjacency with 𝑝 = 〈3,4〉?
Solution 12
The conditions for 8- adjacency between 𝑝 and 𝑞 are
𝑓(𝑝) ∈ 𝑉 Yes Hence, 𝑞 = 〈2,3〉, 𝑞 = 〈3,5〉, 𝑞 = 〈4,4〉, and 𝑞 =
𝑓(𝑞) ∈ 𝑉 Yes 〈4,5〉 satisfy the three conditions and have 8-adjacency
𝑞 ∈ 𝑁8 (𝑝) Yes with 𝑝 = 〈3,4〉.
Example 13
What are the conditions for m-adjacency between two pixels?
Solution 13
𝑓(𝑝) ∈ 𝑉
𝑓(𝑝) ∈ 𝑉
𝑓(𝑞) ∈ 𝑉
𝑓(𝑞) ∈ 𝑉
OR 𝑞 ∈ 𝑁8 (𝑝)
𝑞 ∈ 𝑁4 (𝑝)
𝑓(𝑁4 (𝑝) ∩ 𝑁4 (𝑞)) ∉ 𝑉
Example 14
Does 𝑞 = 〈4,4〉 has m- adjacency with 𝑝 = 〈3,4〉?
Solution 14
𝑓(𝑝) ∈ 𝑉 Yes Yes, because 𝑞 = 〈4,4〉 satisfies the three conditions.
𝑓(𝑞) ∈ 𝑉 Yes
𝑞 ∈ 𝑁4 (𝑝) Yes
Example 15
Does 𝑞 = 〈4,5〉 has m-adjacency with 𝑝 = 〈3,4〉?
Solution 15
𝑓(𝑝) ∈ 𝑉 Yes
𝑓(𝑞) ∈ 𝑉 Yes No, 𝑞 = 〈4,5〉 has no m-adjacency with 𝑝 = 〈3,4〉,
𝑞 ∈ 𝑁8 (𝑝) Yes because both points of 𝑁4 (3,4) ∩ 𝑁4 (4,5) belong to V.
𝑓(𝑁4 (𝑝) ∩ 𝑁4 (𝑞)) ∉ 𝑉 No 𝑁4 (3,4) ∩ 𝑁4 (4,5) = {〈3,5〉, 𝟐𝟏𝟏; 〈4,4〉, 𝟓𝟎}
Example 16
Does 𝑞 = 〈2,3〉 has m-adjacency with 𝑝 = 〈3,4〉?
Solution 16
𝑓(𝑝) ∈ 𝑉 Yes
Yes, 𝑞 = 〈2,3〉 has m-adjacency with 𝑝 = 〈3,4〉,
𝑓(𝑞) ∈ 𝑉 Yes
because no point of 𝑁4 (3,4) ∩ 𝑁4 (2,3) belong to V.
𝑞 ∈ 𝑁8 (𝑝) Yes
𝑁4 (3,4) ∩ 𝑁4 (2,3) = {〈2,4〉, 230; 〈3,3〉, 89}
𝑓(𝑁4 (𝑝) ∩ 𝑁4 (𝑞)) ∉ 𝑉 Yes
Example 17
Let an image consists of nine regions and the foreground of this image consists of
𝐹 = 𝑅2 ∪ 𝑅5 ∪ 𝑅8 . Find the background of this image?
Solution 17
𝐵 = 𝑅1 ∪ 𝑅3 ∪ 𝑅4 ∪ 𝑅6 ∪ 𝑅7 ∪ 𝑅9
Example 18
Find Euclidean, city-block, and chessboard distances between 𝑞 = 〈2,3〉 and 𝑝 = 〈5,4〉?
Solution 18
The Euclidean distance is
𝐷𝑒 (𝑝, 𝑞) = √|𝑥 − 𝑠|2 + |𝑦 − 𝑡|2 = √|2 − 5|2 + |3 − 4|2 = 3.16
The city-block distance is
𝐷4 (𝑝, 𝑞) = |𝑥 − 𝑠| + |𝑦 − 𝑡| = |2 − 5| + |3 − 4| = 4
The chessboard distance is
𝐷8 (𝑝, 𝑞) = max(|𝑥 − 𝑠|, |𝑦 − 𝑡|) = max(3,1) = 3
Example 1
What are the 2D Gaussian filter weights for the pixel 〈0,0〉 and 〈0,1〉 if 𝜎 = 1?
Solution 1
1 𝑥2 + 𝑦2
ℎ(𝑥, 𝑦) = exp (− )
2𝜋𝜎 2 2𝜎 2
1 02 + 12
ℎ(0,1) = exp (− ) = 0.097
2𝜋(1)2 2(1)2
1 02 + 02
ℎ(0,0) = exp (− ) = 0.159
2𝜋(1)2 2(1)2
Example 2
What is the periodic noise model in spatial and frequency domains?
Solution 2
• In spatial domain,
2𝜋𝑢0 (𝑥 + 𝐵𝑥 ) 2𝜋𝑣0 (𝑦 + 𝐵𝑦 )
𝑟(𝑥, 𝑦) = 𝐴 sin [ + ]
𝑀 𝑁
• In frequency domain,
𝐴𝑀𝑁 𝑢0 𝐵𝑥 𝑣0 𝐵𝑦 𝑢0 𝐵𝑥 𝑣0 𝐵𝑦
𝑅(𝑢, 𝑣) = [exp (𝑗2𝜋 ( + )) 𝛿(𝑢 − 𝑢0 , 𝑣 − 𝑣0 ) − exp (−𝑗2𝜋 ( + )) 𝛿(𝑢 + 𝑢0 , 𝑣 + 𝑣0 )]
2𝑗 𝑀 𝑁 𝑀 𝑁
Example 3
Classify the noise type of the following images?
Solution 3
(a) Periodic noise.
(b) Impulse noise (two impulses) (salt and pepper noise).
(c) Impulse noise (one impulse) (pepper noise).
(d) Impulse noise (one impulse) (salt noise).
Example 4
What is the noise model of the following:
Example 5
What is the spatial filtering result of a 3 × 3 arithmetic mean filter with the following
image matrix?
23 45 56
𝑓(𝑥, 𝑦) = [02 67 99]
50 25 43
Solution 5
The 3 × 3 arithmetic mean filter is represented by the following matrix
1 1 1 1
ℎ(𝑥, 𝑦) = [1 1 1]
9
1 1 1
The filter is symmetric and then the summation of the point-wise multiplication between
the image patch and the filter yields the new value for each pixel.
43 50 25 1 1 1 1 1 43 50 25
𝑔(1,1) = ∑ ([56 23 45] . [1 1 1]) = ∑ ([56 23 45]) = 45.56
9 9
99 02 67 1 1 1 99 02 67
Similarly, we can get the values for the remaining pixels.
45.56 45.56 45.56
𝑔(𝑥, 𝑦) = [45.56 45.56 45.56]
45.56 45.56 45.56
Note that all value of 𝑔(𝑥, 𝑦) have the same values because the image size is like the
filter size.
Example 6
Use a 3 × 3 geometric mean filter to filter 23 45 56
𝑓(𝑥, 𝑦) = [02 67 99]
the following image matrix? 50 25 43
Solution 6
The filtered pixel value using 3 × 3 geometric mean filter is given by:
1
𝑚𝑛
𝑚𝑛
𝑔(𝑥, 𝑦) = √ ∏ 𝑓(𝑠, 𝑡) = ( ∏ 𝑓(𝑠, 𝑡))
〈𝑠,𝑡〉∈𝑆𝑥𝑦 〈𝑠,𝑡〉∈𝑆𝑥𝑦
Example 7
Use a 3 × 3 harmonic mean filter to filter the following image matrix?
23 45 56
𝑓(𝑥, 𝑦) = [02 67 99]
50 25 43
Solution 7
The filtered pixel value using 3 × 3 harmonic mean filter is given by:
𝑚𝑛 9
𝑔(𝑥, 𝑦) = 1 = 1
∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 ∑〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑓(𝑠,𝑡) 𝑓(𝑠,𝑡)
9
𝑔(1,1) = = 13
1/43 1/50 1/25
∑ ([1/56 1/23 1/45])
1/99 1/02 1/67
The filtered image is:
13 13 13
𝑔(𝑥, 𝑦) = [13 13 13]
13 13 13
Example 8
Use a second order 3 × 3 contra-harmonic mean filter to filter the following image
matrix?
23 45 56
𝑓(𝑥, 𝑦) = [02 67 99]
50 25 43
Solution 8
The filtered pixel value using 3 × 3 contra-harmonic mean filter is given by:
∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 𝑓(𝑠, 𝑡)𝑄+1 ∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 𝑓(𝑠, 𝑡)3
𝑔(𝑥, 𝑦) = =
∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 𝑓(𝑠, 𝑡)𝑄 ∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 𝑓(𝑠, 𝑡)2
Example 1
What is the image operation done for the following:
(a) (b)
(c) (d)
Solution 1
(a) Image enhancement.
(b) Image negative.
(c) Image thresholding.
(d) Log transformation.
Example 2
Power low transformation is done for the following two images. Specify the range of
gamma parameter for each one of them and give reason for that?
Solution 2
(a) Gamma smaller than one because we increase the contrast.
(b) Gamma greater than one because we decrease the contrast.
(a) (b)
Example 3
What is the new value of 𝑓(𝑥, 𝑦) = 185, if we do the following point processing:
(a) Image negative with 𝐿 = 256.
(b) Threshold transformation with 𝑚 = 110.
(c) Log transformation with 𝑐 = 2.
(d) Gamma transformation with 𝑐 = 2 and 𝛾 = 3.
(e) Gamma transformation with 𝑐 = 2 and 𝛾 = 0.7.
(f) Gamma transformation with 𝑐 = 2 and 𝛾 = 3 after normalization.
(g) Constant stretching with 𝑚 = 110, and 𝐸 = 1.2.
Solution 3
(a) 𝑠 = 𝑇(𝑟) = 𝐿 − 1 − 𝑟 = 256 − 1 − 185 = 70
1 𝑟 ≥ 110
(b) 𝑠 = 𝑇(𝑟) = { =1
0 𝑟 < 110
(c) 𝑠 = 𝑐 log(1 + 𝑟) = 2 log(1 + 185) = 4.54
(d) 𝑠 = 𝑐𝑟 𝛾 = 2 × 1853 = 12663250
(e) 𝑠 = 𝑐𝑟 𝛾 = 2 × 1850.7 = 77.28
185 3
(f) 𝑠 = 𝑐𝑟 𝛾 = 2 × ( ) = 0.7637
255
1 1
(g) 𝑠 = = = 0.651
1+(𝑚/𝑟)𝐸 1+(110/185)1.2
Example 4
What is the thresholded image of 𝑓(𝑥, 𝑦) if THR= 50?
21 10 20 0 0 0
𝑓(𝑥, 𝑦) = [56 67 46] → 𝑔(𝑥, 𝑦) = [1 1 0]
23 48 89 0 0 1
Example 5
What is the input and output dynamic ranges of log transformation with 𝐿 = 512, and
𝑐 = 1?
Solution 5
Input dynamic range is [0,511]. The output range is [0,2.71].
𝑠1 = log(1 + 𝑟1 ) = log(1 + 0) = 0
Example 6
Enhance the dynamic range of the following image matrix by linearly stretching the
original gray levels to new range, [0, 255]?
10 15 5 15 85 170 0 170
5 5 20 10 0 0 255 85
20 10 20 15 255 85 255 170
10 20 5 10 85 255 0 85
Solution 6
The old gray levels belong to [𝑟1 , 𝑟2 ] = [5,20] and the new range belong to [𝑠1 , 𝑠2 ] =
[0,255].
𝑠2 − 𝑠1 255 − 0 255(𝑟 − 5)
𝑠= (𝑟 − 𝑟1 ) + 𝑠1 = (𝑟 − 5) + 0 = = 17(𝑟 − 5)
𝑟2 − 𝑟1 20 − 5 15
𝑠 = 17(𝑟 − 5) = 17(5 − 5) = 0
𝑠 = 17(𝑟 − 5) = 17(10 − 5) = 85
𝑠 = 17(𝑟 − 5) = 17(15 − 5) = 170
𝑠 = 17(𝑟 − 5) = 17(20 − 5) = 255
Example 7
Write a piece-wise function for the figure
besides given that 〈𝑟1 , 𝑠1 〉 = 〈𝐿/4, 𝐿/4〉 ,
and 〈𝑟2 , 𝑠2 〉 = 〈3𝐿/4, 𝐿/2〉?
Solution 7
𝑠1 − 𝑠2
𝑇(𝑟) − 𝑠1 = (𝑟 − 𝑟1 )
𝑟1 − 𝑟2
The starting and end points of the first piece are 〈0,0〉, and 〈𝐿/4, 𝐿/4〉. Hence,
𝑠1 − 𝑠2
𝑇(𝑟) − 𝑠1 = (𝑟 − 𝑟1 ) = 𝑟
𝑟1 − 𝑟2
The starting and end points of the second piece are 〈𝐿/4, 𝐿/4〉, and 〈3𝐿/4, 𝐿/2〉. Hence,
𝐿/4 − 𝐿/2
𝑇(𝑟) − 𝐿/4 = (𝑟 − 𝐿/4)
𝐿/4 − 3𝐿/4
4𝑟 + 𝐿
𝑇(𝑟) =
8
The starting and end points of the third piece are 〈3𝐿/4, 𝐿/2〉, and 〈𝐿 − 1, 𝐿 − 1〉. Hence,
𝐿
−𝐿+1
2
𝑇(𝑟) − 𝐿/2 = 3𝐿
(𝑟 − 3𝐿/4)
−𝐿+1
4
4 − 2𝐿 4𝑟 − 3𝐿 𝐿
𝑇(𝑟) = ( ) +
4−𝐿 4 2
(a) (b)
Solution 8
10 0 ≤ 𝑟 ≤ 120 or 180 ≤ 𝑟 ≤ 255
(a) 𝑠 = 𝑇(𝑟) = {
170 120 < 𝑟 < 180
𝑟 0 ≤ 𝑟 ≤ 120 or 180 ≤ 𝑟 ≤ 255
(b) 𝑠 = 𝑇(𝑟) = {
170 120 < 𝑟 < 180
Example 9
A given image (a) is transformed using two intensity level slicing functions of Example
8. What is the intensity level slicing function used for images (b) and (c)? Give reasons?
Solution 9
• The intensity level slicing function (a) (Example 8) is used for image (b) because
the image has only two intensity levels (black and white).
• The intensity level slicing function (b) (Example 8) is used for image (c) because
the image has more than two intensity levels.
Example 10
Find the normalized histogram of the following matrix?
7 100 200 45 Level Count Normalized Count
2 1 0.05
2 100 7 120
7 3 0.15
100 100 7 120
45 4 0.20
200 100 45 100
100 6 0.30
200 200 45 45 120 2 0.10
200 4 0.20
Solution 10 0.30
0.25
0.20
0.15
𝑛𝑘 0.10
ℎ(𝑟𝑘 ) = 0.05
𝑀𝑁 002 007 045 100 120 200
Example 11
Find the correlation and convolution
between the image 𝑓(𝑥, 𝑦) and 𝑤(𝑥, 𝑦)?
Example 12
What is the mask for the following:
Solution 12
1 1 1
ℎ(𝑥, 𝑦) = [ ]
4 1 1
Example 13
A given image has the following intensity frequencies. Find the following:
𝑟𝑘 0 1 2 3 4 5 6 7
𝑛𝑘 790 1023 850 656 329 245 122 81
(a) Number of image pixels?
(b) Number of intensity levels?
(c) Normalized frequencies?
(d) Equalized distribution?
Solution 13
(a) Number of pixels is the sum of all frequencies = 4096.
(b) Intensity levels = 8.
(c) The following table gives the normalized values.
𝑛𝑘
ℎ(𝑟𝑘 ) =
𝑀𝑁
Example 14
Discuss the need for histogram equalization through an example?
Solution 14
Example 15
Complete the matrix 𝑔 if you have 𝑓 and ℎ? What is the type of this filter?
Example 16
List three smoothing filters for image spatial filtering?
Solution 16
Example 17
First and second derivatives illustrate the changes.
Example 18
𝜕𝑓 𝜕𝑓 𝜕2 𝑓 𝜕2 𝑓
Find the 3 × 3 filter mask for , , 2
, and ?
𝜕𝑥 𝜕𝑦 𝜕𝑥 𝜕𝑦 2
Solution 18
𝜕𝑓
= 𝑓(𝑥 + 1) − 𝑓(𝑥) = 𝑓(𝑥 + 1, 𝑦) − 𝑓(𝑥, 𝑦)
𝜕𝑥
𝜕𝑓
= 𝑓(𝑦 + 1) − 𝑓(𝑦) = 𝑓(𝑥, 𝑦 + 1) − 𝑓(𝑥, 𝑦)
𝜕𝑦
𝜕2𝑓
= 𝑓(𝑥 + 1) − 2𝑓(𝑥) + 𝑓(𝑥 − 1) = 𝑓(𝑥 + 1, 𝑦) − 2𝑓(𝑥, 𝑦) + 𝑓(𝑥 − 1, 𝑦)
𝜕𝑥 2
𝜕2𝑓
= 𝑓(𝑦 + 1) − 2𝑓(𝑦) + 𝑓(𝑦 − 1) = 𝑓(𝑥, 𝑦 + 1) − 2𝑓(𝑥, 𝑦) + 𝑓(𝑥, 𝑦 − 1)
𝜕𝑦 2
𝑥 − 1, 𝑦 − 1 𝑥 − 1, 𝑦 𝑥 − 1, 𝑦 + 1
ℎ = [𝑥 − 1, 𝑦 − 1 𝑥 − 1, 𝑦 𝑥 + 1, 𝑦 + 1]
𝑥 + 1, 𝑦 − 1 𝑥 + 1, 𝑦 𝑥 + 1, 𝑦 + 1
0 −0 0 0 −1 0
ℎ𝜕𝑥 = [0 −1 0] ℎ 𝜕𝑥 2 = [0 −2 0]
0 −1 0 0 −1 0
0 −0 0 0 −0 0
ℎ𝜕𝑦 = [0 −1 1] ℎ𝜕𝑦2 = [1 −2 1]
0 −0 0 0 −0 0
Example 19
Find
𝜕𝑓
and
𝜕𝑓
for 𝑓(𝑥, 𝑦)? 21 10 20
𝜕𝑥 𝜕𝑦 𝑓(𝑥, 𝑦) = [56 67 46]
23 48 89
𝜕𝑓 −11 −10 −01 𝜕𝑓 −35 −57 26
= [−11 −21 −10] = [−33 −19 43]
𝜕𝑦 𝜕𝑥
−25 −41 −66 −02 −38 69
Solution 19
21 10 20 21 10 20 21 10 20
56 67 46 56 67 46 56 67 46
23 48 89 23 48 89 23 48 89
21 10 20 21 10 20 21 10 20
56 67 46 56 67 46 56 67 46
23 48 89 23 48 89 23 48 89
21 10 20 21 10 20 21 10 20
56 67 46 56 67 46 56 67 46
23 48 89 23 48 89 23 48 89
Example 20
Find the Laplacian image for the image defined by 𝐹 in Example 18?
Solution 20
The Laplacian image can be found from
2
𝜕2𝑓 𝜕2𝑓
∇ 𝑓= 2+ 2
𝜕𝑥 𝜕𝑦
Example 21
Sharpen the image F (Example 18) using Laplacian filter in Example 19 if 𝑐 = 1?
Solution 21
The sharpened image is given by
𝑔(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝑐[∇2 𝑓(𝑥, 𝑦)]
21 10 20 −25 −116 −086 −46 126 −106
𝑔(𝑥, 𝑦) = [56 67 46] + [−67 −108 −048] = [−11 −41 −094]
23 48 89 122 −003 −219 145 −45 −130
Example 22
What are the operations done for converting image (a) into image (b) for each case?
1
(a) (b)
Solution 22
(1) Histogram equalization.
(2) Sharpening.
(3) Sharpening.
(4) Sharpening.
(5) Smoothing.
(6) Smoothing of the background.
Example 23
Write down the DFT pair of 8-point discrete sequence?
Solution 23
7
7
1
IDFT 𝑓(𝑥) = ∑ 𝐹(𝑢)𝑒 𝑗𝜋𝑢𝑥/4 𝑥 = 0,1, … ,7
8
𝑢=0
Example 24
Write down the DFT pair of 8 × 16 digital image?
Solution 24
7 15
−𝑗𝜋(
𝑢𝑥 𝑣𝑦
+ )
𝑢 = 0,1, … ,7
DFT 𝐹(𝑢, 𝑣) = ∑ ∑ 𝑓(𝑥, 𝑦)𝑒 4 8
𝑥=0 𝑦=0
𝑣 = 0,1, … ,15
7 15
1 𝑢𝑥 𝑣𝑦
𝑗𝜋( + )
𝑥 = 0,1, … ,7
IDFT 𝑓(𝑥, 𝑦) = ∑ ∑ 𝐹(𝑢, 𝑣)𝑒 4 8
128 𝑦 = 0,1, … ,15
𝑢=0 𝑣=0
Example 25
What is the DFT value, 𝐹(0,0), of an 8 × 16 digital image?
Solution 25
7 15 7 15
0 0
−𝑗𝜋( + )
𝐹(0,0) = ∑ ∑ 𝑓(𝑥, 𝑦)𝑒 4 8 = ∑ ∑ 𝑓(𝑥, 𝑦)
𝑥=0 𝑦=0 𝑥=0 𝑦=0
Example 26
Which of the
following images
represent a shifted
Fourier transform?
Why?
(a) (b)
Solution 26
Image (b) represents an image for shifted FT because all low frequencies are
concentrated in the middles not the corners.
Example 27
Draw a block diagram for implementing frequency domain techniques to images?
Solution 27
Example 28
What we mean by ideal LPF digital filter?
Solution 28
We mean that the filter passes with no attenuation all frequencies inside a circle of radius
𝐷0 whereas completely attenuates all frequencies outside this circle.
Example 29
What is the factor used for centering the FT in spatial domain?
Solution 29
𝑓(𝑥, 𝑦) → 𝑓(𝑥, 𝑦)(−1)𝑥+𝑦
Example 30
What is the size of the padded image for direct filtering in frequency domain if the
original image size is 680 × 480 pixel? How many zero pixels are padded?
Solution 30
𝑃 = 2𝑀 = 2(680) = 1360
𝑄 = 2𝑁 = 2(480) = 960
The image spatial resolution is
𝑁𝑝 = 𝑀 × 𝑁 = 680 × 480 = 326400 pixels
The padded image spatial resolution is
𝑃𝑝 = 𝑃 × 𝑄 = 4𝑁𝑝 = 1360 × 960 = 1305600 pixels
The number of padded zeros is
𝑍𝑝 = 𝑃𝑝 − 𝑁𝑝 = 1305600 − 326400 = 979200 pixels
𝑍𝑝 = 2𝑀 × 2𝑁 − 𝑀 × 𝑁 = 4(𝑀 × 𝑁) − (𝑀 × 𝑁) = 3(𝑀 × 𝑁)
𝑍𝑝 = 3(326400) = 979200 pixels
Example 31
What is the size of the padded image for convolution via frequency domain if the original
image size is 680 × 480 pixel and the spatial filter is 512 × 480 pixel? How many zero
pixels are padded?
Solution 31
𝑃 = 𝐴 + 𝐶 − 1 = 680 + 512 − 1 = 1191
𝑄 = 𝐵 + 𝐷 − 1 = 480 + 480 − 1 = 959
The image spatial resolution is
𝑁𝑝 = 𝑀 × 𝑁 = 680 × 480 = 326400 pixels
The padded image spatial resolution is
𝑃𝑝 = 𝑃 × 𝑄 = 1191 × 959 = 1142169 pixels
Example 32
What is the type of operation for the following images?
(a) (b)
Solution 32
(a) Zero padding for convolution via frequency domain.
(b) Zero padding for direct filtering in frequency domain.
Example 33
What is the distance between any point 〈𝑢, 𝑣〉 and the center (origin) of the FT of an
𝑀 × 𝑁 digital image?
Solution 33
𝑀 2 𝑁 2
𝐷(𝑢, 𝑣) = √(𝑢 − ) + (𝑣 − )
2 2
Example 34
What is the distance between a point 𝑝 = 〈5,12〉 and the center (origin) of the FT of an
8 × 16 digital image?
Solution 34
𝐷(5,12) = √(𝑢 − 4)2 + (𝑣 − 8)2 = √(5 − 4)2 + (12 − 8)2 = 4.123
Example 35
What is the filter value of a point 𝑝 = 〈5,12〉 in an 8 × 16 digital image if 𝐷0 = 25, and
the filter is:
(a) Ideal low pass filter (ILPF)?
(b) Butterworth low pass filter (BLPF) with 𝑛 = 3?
(c) Gaussian low pass filter (GLPF)?
Solution 35
𝐷(5,12) = √(𝑢 − 4)2 + (𝑣 − 8)2 = √(5 − 4)2 + (12 − 8)2 = 4.123
Ideal low pass filter
1 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = { =1
0 𝐷(𝑢, 𝑣) > 𝐷0
Butterworth low pass filter
1 1
𝐻(𝑢, 𝑣) = = =1
1 + [(𝐷(𝑢, 𝑣)/𝐷0 )]2𝑛 1 + [(4.123/25)]6
Gaussian low pass filter
2 (𝑢,𝑣)/2𝐷2 2 /2(25)2
𝐻(𝑢, 𝑣) = 𝑒 −𝐷 0 = 𝑒 −4.123 = 0.9865
Example 36
What is the filter value of a point 𝑝 = 〈5,12〉 in an 8 × 16 digital image if 𝐷0 = 5, and
the filter is:
(a) Ideal low pass filter (ILPF)?
(b) Butterworth low pass filter (BLPF) with 𝑛 = 3?
(c) Gaussian low pass filter (GLPF)?
Solution 36
𝐷(5,12) = √(𝑢 − 4)2 + (𝑣 − 8)2 = √(5 − 4)2 + (12 − 8)2 = 4.123
Ideal low pass filter
1 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = { =1
0 𝐷(𝑢, 𝑣) > 𝐷0
Butterworth low pass filter
1 1
𝐻(𝑢, 𝑣) = = = 0.761
1 + [(𝐷(𝑢, 𝑣)/𝐷0 )]2𝑛 1 + [(4.123/5)]6
Gaussian low pass filter
2 (𝑢,𝑣)/2𝐷2 2 /2(5)2
𝐻(𝑢, 𝑣) = 𝑒 −𝐷 0 = 𝑒 −4.123 = 0.712
Example 37
What is the filter value of a point 𝑝 = 〈5,12〉 in an 8 × 16 digital image if 𝐷0 = 5, and
the filter is:
(a) Ideal high pass filter (IHPF)?
(b) Butterworth high pass filter (BHPF) with 𝑛 = 3?
(c) Gaussian high pass filter (GHPF)?
Solution 37
𝐻𝐻𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐿𝑃 (𝑢, 𝑣)
Ideal high pass filter
𝐻𝐻𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐿𝑃 (𝑢, 𝑣) = 1 − 1 = 0
Butterworth high pass filter
𝐻𝐻𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐿𝑃 (𝑢, 𝑣) = 1 − 0.761 = 0.239
Gaussian low pass filter
𝐻𝐻𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐿𝑃 (𝑢, 𝑣) = 1 − 0.712 = 0.288
Example 38
What is the filter value of a point 𝑝 = 〈150,180〉 in an 320 × 230 digital image if 𝐷0 =
35, and the filter is:
(a) Ideal high pass filter (IHPF)?
(b) Butterworth high pass filter (BHPF) with 𝑛 = 2?
(c) Gaussian high pass filter (GHPF)?
Solution 38
𝐷(150,180) = √(𝑢 − 160)2 + (𝑣 − 115)2 = √(150 − 160)2 + (180 − 115)2 = 65.8
Ideal high pass filter
0 𝐷(𝑢, 𝑣) ≤ 𝐷0
𝐻(𝑢, 𝑣) = { =1
1 𝐷(𝑢, 𝑣) > 𝐷0
Butterworth high pass filter
1 1
𝐻(𝑢, 𝑣) = = = 0.926
1 + [𝐷0 /𝐷(𝑢, 𝑣)]2𝑛 1 + [(35/65.8)]4
Gaussian low pass filter
2 (𝑢,𝑣)/2𝐷2 2 /2(35)2
𝐻(𝑢, 𝑣) = 1 − 𝑒 −𝐷 0 = 1 − 𝑒 −65.8 = 0.829
Example 39 01 02 03 04 05
06 07 08 09 10 0 0 0
Find the convolution between the image 11 12 13 14 15 0 0 1
16 17 18 19 20 0 0 0
𝑓(𝑥, 𝑦) and ℎ(𝑥, 𝑦)? 21 22 23 24 25
Rotated h
25 21 22 23 24 25 21 05 01 02 03 04
0 0 0 23 24 25 21 10 06 07 08 09
05 01 02 03 04 05 01
1 0 0 03 04 05 01 15 11 12 13 14
10 06 07 08 09 10 06
0 0 0 08 09 10 06 20 16 17 18 19
15 11 12 13 14 15 11
15 11 12 13 14 15 11 25 21 22 23 24
20 16 17 18 19 20 16
20 16 17 18 19 20 16
25 21 22 23 24 25 21
25 21 22 23 24 25 21 Shift right by 1 pixel
05 01 02 03 04 05 01
05 01 02 03 04 05 01
Example 40 01 02 03 04 05
06 07 08 09 10 0 0 0
Find the convolution between the image 11 12 13 14 15 1 0 0
16 17 18 19 20 0 0 0
𝑓(𝑥, 𝑦) and ℎ(𝑥, 𝑦)? 21 22 23 24 25
Rotated h
25 21 22 23 24 25 21 02 03 04 05 01
0 0 0 23 24 25 21 07 08 09 10 06
05 01 02 03 04 05 01
0 0 1 03 04 05 01 12 13 14 15 11
10 06 07 08 09 10 06
0 0 0 08 09 10 06 17 18 19 20 16
15 11 12 13 14 15 11
15 11 12 13 14 15 11 22 23 24 25 21
20 16 17 18 19 20 16
20 16 17 18 19 20 16
25 21 22 23 24 25 21
25 21 22 23 24 25 21 Shift left by 1 pixel
05 01 02 03 04 05 01
05 01 02 03 04 05 01
Example 1
For a simple degradation model, the noisy image is modeled as follows:
𝑔(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝜂(𝑥, 𝑦)
where the image matrix is 𝑓(𝑥, 𝑦) and the noise matrix is 𝜂(𝑥, 𝑦). Find the noisy image
matrix?
48 53 28 43 52 8 3 2 3 2
52 23 45 56 23 2 3 4 6 3
𝑓(𝑥, 𝑦) = 99 02 67 99 01 𝜂(𝑥, 𝑦) = 6 2 6 7 1
47 50 25 43 50 4 0 2 3 0
[64 20 55 60 21] [6 0 5 0 1]
Solution 1
𝑔(𝑥, 𝑦) = 𝑓(𝑥, 𝑦) + 𝜂(𝑥, 𝑦)
48 53 28 43 52 8 3 2 3 2 56 56 30 46 54
52 23 45 56 23 2 3 4 6 3 54 26 49 62 26
𝑔(𝑥, 𝑦) = 90 02 67 79 01 + 6 2 6 7 1 = 96 04 73 87 02
47 50 25 43 50 4 0 2 3 0 51 50 27 46 50
[64 20 55 60 21] [ 6 0 5 0 1 ] [70 20 60 60 22]
Example 2
Draw a block diagram for the image degradation process?
Solution 2
Example 3
Draw a block diagram for the image restoration process?
Solution 3
Example 4
Use 3 × 3 arithmetic mean filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 4
The 3 × 3 arithmetic mean filter is represented by the following matrix
1 1 1 1
ℎ(𝑥, 𝑦) = [1 1 1]
9
1 1 1
The extended image matrix is
21 64 20 55 60 21 64
52 𝟒𝟖 𝟓𝟑 𝟐𝟖 𝟒𝟑 𝟓𝟐 48
23 𝟓𝟐 𝟐𝟑 𝟒𝟓 𝟓𝟔 𝟐𝟑 52
01 𝟗𝟗 𝟎𝟐 𝟔𝟕 𝟗𝟗 𝟎𝟏 99
50 𝟒𝟕 𝟓𝟎 𝟐𝟓 𝟒𝟑 𝟓𝟎 47
21 𝟔𝟒 𝟐𝟎 𝟓𝟓 𝟔𝟎 𝟐𝟏 64
52 48 53 28 43 52 48
The restored image is:
39.56 43.11 42.56 42.56 46.56
𝑓̂(𝑥, 𝑦) =
[ ]
Example 5
Use 3 × 3 geometric mean filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 5
The restored pixel value using 3 × 3 geometric mean filter is given by:
1
𝑚𝑛
𝑓̂(𝑥, 𝑦) = 𝑚𝑛
√ ∏ 𝑔(𝑠, 𝑡) = ( ∏ 𝑔(𝑠, 𝑡))
〈𝑠,𝑡〉∈𝑆𝑥𝑦 〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑓̂(𝑥, 𝑦) =
[ ]
Example 6
Use 3 × 3 harmonic mean filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 6
The restored pixel value using 3 × 3 harmonic mean filter is given by:
𝑚𝑛 9
𝑓̂(𝑥, 𝑦) = 1 = 1
∑〈𝑠,𝑡〉∈𝑆𝑥𝑦 ∑〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑔(𝑠,𝑡) 𝑔(𝑠,𝑡)
𝑓̂(𝑥, 𝑦) =
[ ]
Example 7
Use a second order 3 × 3 contra-harmonic mean filter to restore the following noisy
image matrix? Which type of the noise this filter can eliminate?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 7
The restored pixel value using a Q-order 3 × 3 contra-harmonic mean filter is given by:
𝑓̂(𝑥, 𝑦) =
[ ]
Because 𝑄 > 1, this filter can eliminate pepper noise.
Example 8
Use a 3 × 3 median filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 8
The restored pixel value using a 3 × 3 median filter is given by:
𝑓̂(𝑥, 𝑦) = median{𝑔(𝑠, 𝑡)}
〈𝑠,𝑡〉∈𝑆𝑥𝑦
48 48 45 45 52
𝑓̂(𝑥, 𝑦) =
[ ]
Example 9
Use a 3 × 3 maximum filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 9
The restored pixel value using a 3 × 3 maximum filter is given by:
𝑓̂(𝑥, 𝑦) = max {𝑔(𝑠, 𝑡)}
〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑓̂(𝑥, 𝑦) =
[ ]
Example 10
Use a 3 × 3 minimum filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 10
The restored pixel value using a 3 × 3 minimum filter is given by:
𝑓̂(𝑥, 𝑦) = min {𝑔(𝑠, 𝑡)}
〈𝑠,𝑡〉∈𝑆𝑥𝑦
21 64 20 55 60 21 64
52 𝟒𝟖 𝟓𝟑 𝟐𝟖 𝟒𝟑 𝟓𝟐 48
23 𝟓𝟐 𝟐𝟑 𝟒𝟓 𝟓𝟔 𝟐𝟑 52
01 𝟗𝟗 𝟎𝟐 𝟔𝟕 𝟗𝟗 𝟎𝟏 99
50 𝟒𝟕 𝟓𝟎 𝟐𝟓 𝟒𝟑 𝟓𝟎 47
21 𝟔𝟒 𝟐𝟎 𝟓𝟓 𝟔𝟎 𝟐𝟏 64
52 48 53 28 43 52 48
The restored image for this filter is:
20 20 20 21 21
𝑓̂(𝑥, 𝑦) =
[ ]
Example 11
Use a 3 × 3 mid-point filter to restore the following noisy image matrix?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 11
The restored pixel value using a 3 × 3 mid-point filter is given by:
min {𝑔(𝑠, 𝑡)} + max {𝑔(𝑠, 𝑡)}
〈𝑠,𝑡〉∈𝑆𝑥𝑦 〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑓̂(𝑥, 𝑦) =
2
The extended image matrix is
21 64 20 55 60 21 64
52 𝟒𝟖 𝟓𝟑 𝟐𝟖 𝟒𝟑 𝟓𝟐 48
23 𝟓𝟐 𝟐𝟑 𝟒𝟓 𝟓𝟔 𝟐𝟑 52
01 𝟗𝟗 𝟎𝟐 𝟔𝟕 𝟗𝟗 𝟎𝟏 99
50 𝟒𝟕 𝟓𝟎 𝟐𝟓 𝟒𝟑 𝟓𝟎 47
21 𝟔𝟒 𝟐𝟎 𝟓𝟓 𝟔𝟎 𝟐𝟏 64
52 48 53 28 43 52 48
The restored image for this filter is:
42 42 40 40.5 42.5
𝑓̂(𝑥, 𝑦) =
[ ]
Example 12
Use a 3 × 3 alpha-trimmed mean filter to restore the following noisy image matrix if 𝛼 =
4?
48 53 28 43 52
52 23 45 56 23
𝑔(𝑥, 𝑦) = 99 02 67 99 01
47 50 25 43 50
[64 20 55 60 21]
Solution 12
The restored pixel value using 3 × 3 alpha-trimmed mean filter is given by:
1 1
𝑓̂(𝑥, 𝑦) = ∑ 𝑔𝑟 (𝑠, 𝑡) = ∑ 𝑔𝑟 (𝑠, 𝑡)
𝑚𝑛 − 𝛼 5
〈𝑠,𝑡〉∈𝑆𝑥𝑦 〈𝑠,𝑡〉∈𝑆𝑥𝑦
𝑓̂(𝑥, 𝑦) =
[ ]
Example 13
Use 3 × 3 adaptive median filter to restore the first row of the following noisy image
matrix? Assume 𝑆𝑚𝑎𝑥 = 5?
251 143 50 47 248
152 64 248 55 255 152 64 248
255 152 05 89 255
255 255 152 05 89 255 255 152
255 123 45 255 76
76 255 123 45 255 76 255 123
99 02 167 99 33
33 99 02 167 99 33 99 02
47 50 251 143 50
50 47 50 251 143 50 47 50
64 248 55 255 152
01 64 248 55 255 152 64 248
250 253 152 05 89 250 253
Solution 13
The restored pixel value using adaptive median filter is given by:
𝑧𝑚𝑖𝑛 = 64, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 152, 𝑧𝑥𝑦 = 255. 𝐵1 = 𝑧𝑥𝑦 − 𝑧𝑚𝑖𝑛 = 255 − 64 = 191 (+)
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 152 − 64 = 88 (+) 𝐵2 = 𝑧𝑥𝑦 − 𝑧𝑚𝑎𝑥 = 255 − 255 = 0 (0)
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 152 − 255 = −103 (-) 𝑓̂(1,1) = 𝑧𝑚𝑒𝑑 = 152
𝑧𝑚𝑖𝑛 = 5, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 123, 𝑧𝑥𝑦 = 152. 𝐵1 = 𝑧𝑥𝑦 − 𝑧𝑚𝑖𝑛 = 152 − 5 = 147 (+)
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 123 − 5 = 118 (+) 𝐵2 = 𝑧𝑥𝑦 − 𝑧𝑚𝑎𝑥 = 152 − 255 = −103 (-)
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 123 − 255 = −132 (-) 𝑓̂(1,2) = 𝑧𝑥𝑦 = 152
𝑧𝑚𝑖𝑛 = 5, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 123, 𝑧𝑥𝑦 = 5. 𝐵1 = 𝑧𝑥𝑦 − 𝑧𝑚𝑖𝑛 = 5 − 5 = 0 (0)
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 123 − 5 = 118 (+) 𝐵2 = 𝑧𝑥𝑦 − 𝑧𝑚𝑎𝑥 = 5 − 255 = −250 (-)
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 123 − 255 = −132 (-) 𝑓̂(1,3) = 𝑧𝑚𝑒𝑑 = 123
𝑧𝑚𝑖𝑛 = 5, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 89, 𝑧𝑥𝑦 = 89. 𝐵1 = 𝑧𝑥𝑦 − 𝑧𝑚𝑖𝑛 = 89 − 5 = 84 (+)
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 89 − 5 = 84 (+) 𝐵2 = 𝑧𝑥𝑦 − 𝑧𝑚𝑎𝑥 = 89 − 255 = −166 (-)
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 89 − 255 = −166 (-) 𝑓̂(1,4) = 𝑧𝑥𝑦 = 89
𝑧𝑚𝑖𝑛 = 64, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 255, 𝑧𝑥𝑦 = 255.
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 255 − 64 = 191 (+) 𝑆𝑥𝑦 = 𝑆𝑥𝑦 + 2 = 3 + 2 = 5
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 255 − 255 = 0 (0)
𝑧𝑚𝑖𝑛 = 2, 𝑧𝑚𝑎𝑥 = 255, 𝑧𝑚𝑒𝑑 = 152, 𝑧𝑥𝑦 = 255. 𝐵1 = 𝑧𝑥𝑦 − 𝑧𝑚𝑖𝑛 = 255 − 2 = 253 (+)
𝐴1 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑖𝑛 = 152 − 2 = 150 (+) 𝐵2 = 𝑧𝑥𝑦 − 𝑧𝑚𝑎𝑥 = 255 − 255 = 0 (0)
𝐴2 = 𝑧𝑚𝑒𝑑 − 𝑧𝑚𝑎𝑥 = 152 − 255 = −103 (-) 𝑓̂(1,5) = 𝑧𝑚𝑒𝑑 = 152
𝑓̂(𝑥, 𝑦) =
[ ]
Example 14
Write functions for band reject filter with 𝐷0 = 20, and 𝑊 = 16?
(a) Ideal band reject filter (IBRF)?
(b) Butterworth band reject filter with second order (BBRF)?
(c) Gaussian band reject filter (GBRF)?
Solution 14
The ideal band reject filter is
𝑊 𝑊
𝐻𝐵𝑅 (𝑢, 𝑣) = {0 𝐷0 −
2
≤ 𝐷(𝑢, 𝑣) ≤ 𝐷0 +
2
1 otherwise
0 12 ≤ 𝐷(𝑢, 𝑣) ≤ 28
𝐻𝐵𝑅 (𝑢, 𝑣) = {
1 otherwise
The Butterworth band reject filter is
1
𝐻𝐵𝑅 (𝑢, 𝑣) = 2𝑛
𝑊𝐷(𝑢,𝑣)
1 + [𝐷2(𝑢,𝑣)−𝐷2 ]
0
1
𝐻𝐵𝑅 (𝑢, 𝑣) = 4
16𝐷(𝑢,𝑣)
1+[ 2 (𝑢,𝑣)−400
]
𝐷
2
𝐷2 (𝑢,𝑣)−400
−[ ]
𝐻𝐵𝑅 (𝑢, 𝑣) = 1 − 𝑒 16𝐷(𝑢,𝑣)
Example 15
What is the distance between any point, 〈𝑢, 𝑣〉 and the frequency center,〈0,0〉 of an M×N
digital image?
Solution 15
𝑀 2 𝑁 2
𝐷(𝑢, 𝑣) = √(𝑢 − ) + (𝑣 − )
2 2
Example 16
What is the distance between any point, 〈6,2〉 and the frequency center, 〈0,0〉 of an
8 × 16 digital image?
Solution 16
8 2 16 2
√
𝐷(6,2) = (𝑢 − ) + (𝑣 − ) = √(6 − 4)2 + (2 − 8)2 = 6.325
2 2
Example 17
What is the filter value of a point 𝑝 = 〈6,12〉 of an 24×48 digital image, if 𝐷0 = 25, and
𝑊 = 16?
(a) Ideal band reject filter (IBRF)?
(b) Second order Butterworth band reject filter (BBRF)?
(c) Gaussian band reject filter (GBRF)?
Solution 17
24 2 48 2
𝐷(6,12) = √(𝑢 − ) + (𝑣 − ) = √62 + 122 = 13.42
2 2
𝑊 𝑊
0 17 ≤ 𝐷(𝑢, 𝑣) ≤ 33
𝐻𝐵𝑅 (𝑢, 𝑣) = { 0 𝐷0 −
2
≤ 𝐷(𝑢, 𝑣) ≤ 𝐷0 +
2 = {1 =1
otherwise
1 otherwise
The Butterworth band reject filter is
1
𝐻𝐵𝑅 (𝑢, 𝑣) = 2𝑛
𝑊𝐷(𝑢,𝑣)
1 + [𝐷2(𝑢,𝑣)−𝐷2 ]
0
1 1
𝐻𝐵𝑅 (𝑢, 𝑣) = 4 = 4 = 0.9485
16𝐷(𝑢,𝑣) 214.72
1+[ ] 1+[ ]
𝐷2 (𝑢,𝑣)−625 180.1−625
2
𝐷2 (𝑢,𝑣)−625 180.1−625 2
−[ ] −[ ]
𝐻𝐵𝑅 (𝑢, 𝑣) = 1 − 𝑒 16𝐷(𝑢,𝑣) =1−𝑒 214.72 = 0.9863
Example 18
What is the filter value of a point 𝑝 = 〈6,12〉 of a 24×48 digital image, if 𝐷0 = 25, and
𝑊 = 16?
(a) Ideal band pass filter (IBPF)?
(b) Second order Butterworth band pass filter (BBPF)?
(c) Gaussian band pass filter (GBPF)?
Solution 18
24 2 48 2
𝐷(6,12) = √(𝑢 − ) + (𝑣 − ) = √62 + 122 = 13.42
2 2
𝑊 𝑊
𝐻𝐵𝑅 (𝑢, 𝑣) = {0 𝐷0 −
2
≤ 𝐷(𝑢, 𝑣) ≤ 𝐷0 +
2
1 otherwise
0 17 ≤ 𝐷(𝑢, 𝑣) ≤ 33
𝐻𝐵𝑅 (𝑢, 𝑣) = { =1
1 otherwise
𝐻𝐵𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐵𝑅 (𝑢, 𝑣) = 1 − 1 = 0
The Butterworth band reject filter is
1
𝐻𝐵𝑅 (𝑢, 𝑣) = 2𝑛
𝑊𝐷(𝑢,𝑣)
1 + [𝐷2(𝑢,𝑣)−𝐷2 ]
0
1 1
𝐻𝐵𝑅 (𝑢, 𝑣) = 4 = 4 = 0.9485
16𝐷(𝑢,𝑣) 214.72
1+[ ] 1+[ ]
𝐷2 (𝑢,𝑣)−625 180.1−625
2
𝐷2 (𝑢,𝑣)−𝐷2
0]
−[
𝐻𝐵𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐵𝑅 (𝑢, 𝑣) = 𝑒 𝑊𝐷(𝑢,𝑣)
2
𝐷2 (𝑢,𝑣)−625 180.1−625 2
−[ ] −[ ]
𝐻𝐵𝑅 (𝑢, 𝑣) = 1 − 𝑒 16𝐷(𝑢,𝑣) =1−𝑒 214.72 = 0.9863
𝐻𝐵𝑃 (𝑢, 𝑣) = 1 − 𝐻𝐵𝑅 (𝑢, 𝑣) = 1 − 0.9863 = 0.0137
Example 19
Write functions for the 𝑛-order Butterworth notch reject filter (BNRF) containing two
notch pairs?
Solution 19
The Butterworth notch reject filter containing two notch pairs is:
2
1 1
𝐻𝑁𝑅 (𝑢, 𝑣) = ∏ [ ] [ ]
1 + [𝐷𝑘0 /𝐷𝑘 (𝑢, 𝑣)]2𝑛 1 + [𝐷𝑘0 /𝐷−𝑘 (𝑢, 𝑣)]2𝑛
𝑘=1
1 1
𝐻𝑁𝑅1 (𝑢, 𝑣) = [ ] [ ]
1 + [𝐷10 /𝐷1 (𝑢, 𝑣)]2𝑛 1 + [𝐷10 /𝐷−1 (𝑢, 𝑣)]2𝑛
1 1
𝐻𝑁𝑅2 (𝑢, 𝑣) = [ ] [ ]
1 + [𝐷20 /𝐷2 (𝑢, 𝑣)]2𝑛 1 + [𝐷20 /𝐷−2 (𝑢, 𝑣)]2𝑛
Example 20
Write functions for the Second order Butterworth notch reject filter (BNRF) containing
two notch pairs with 𝐷10 = 20, 𝐷20 = 50, 〈𝑢1 , 𝑣1 〉 = 〈20,35〉, and 〈𝑢2 , 𝑣2 〉 = 〈50,85〉?
Solution 20
2 2 2 2
𝑀 𝑁 𝑀 𝑁
𝐷1 (𝑢, 𝑣 ) = √(𝑢 − − 𝑢1 ) + (𝑣 − − 𝑣1 ) = √(𝑢 − − 20) + (𝑣 − − 35)
2 2 2 2
2 2 2 2
𝑀 𝑁 𝑀 𝑁
𝐷−1 (𝑢, 𝑣 ) = √(𝑢 − √
+ 𝑢1 ) + (𝑣 − + 𝑣1 ) = (𝑢 − + 20) + (𝑣 − + 35)
2 2 2 2
2 2 2 2
𝑀 𝑁 𝑀 𝑁
𝐷2 (𝑢, 𝑣 ) = √(𝑢 − − 𝑢2 ) + (𝑣 − − 𝑣2 ) = √(𝑢 − − 50) + (𝑣 − − 85)
2 2 2 2
2 2 2 2
𝑀 𝑁 𝑀 𝑁
𝐷−2 (𝑢, 𝑣 ) = √(𝑢 − √
+ 𝑢2 ) + (𝑣 − + 𝑣2 ) == (𝑢 − + 50) + (𝑣 − + 85)
2 2 2 2
The Butterworth notch reject filter containing two notch pairs is:
1 1
𝐻𝑁𝑅1 (𝑢, 𝑣) = [ ] [ ]
1 + [𝐷10 /𝐷1 (𝑢, 𝑣)]2𝑛 1 + [𝐷10 /𝐷−1 (𝑢, 𝑣)]2𝑛
1 1
𝐻𝑁𝑅1 (𝑢, 𝑣) = [ ] [ ]
1 + [20/𝐷1 (𝑢, 𝑣)]4 1 + [20/𝐷−1 (𝑢, 𝑣)]4
1 1
𝐻𝑁𝑅2 (𝑢, 𝑣) = [ ] [ ]
1 + [𝐷20 /𝐷2 (𝑢, 𝑣)]2𝑛 1 + [𝐷20 /𝐷−2 (𝑢, 𝑣)]2𝑛
1 1
𝐻𝑁𝑅2 (𝑢, 𝑣) = [ ] [ ]
1 + [50/𝐷2 (𝑢, 𝑣)]4 1 + [50/𝐷−2 (𝑢, 𝑣)]4
Example 21
Find the filter values of 〈𝑢, 𝑣〉 = 〈40,60〉 of an 120×160 digital image,based on the
Second order Butterworth notch reject filter (BNRF) containing two notch pairs with
𝐷10 = 20, 𝐷20 = 50, 〈𝑢1 , 𝑣1 〉 = 〈20,35〉, and 〈𝑢2 , 𝑣2 〉 = 〈50,85〉?
Solution 21
2 2
𝑀 𝑁
𝐷1 (40,60) = √(𝑢 − − 𝑢1 ) + (𝑣 − − 𝑣1 ) = √(40 − 60 − 20)2 + (60 − 80 − 35)2
2 2
= 68.01
2 2
𝑀 𝑁
𝐷−1 (40,60) = √(𝑢 − + 𝑢1 ) + (𝑣 − + 𝑣1 ) = √(40 − 60 + 20)2 + (60 − 80 + 35)2
2 2
= 15
2 2
𝑀 𝑁
𝐷2 (40,60) = √(𝑢 − − 𝑢2 ) + (𝑣 − − 𝑣2 ) = √(40 − 60 − 50)2 + (60 − 80 − 85)2
2 2
= 126.19
2 2
𝑀 𝑁
𝐷−2 (40,60) = √(𝑢 − + 𝑢2 ) + (𝑣 − + 𝑣2 ) = √(40 − 60 + 50)2 + (60 − 80 + 85)2
2 2
= 71.59
The Butterworth notch reject filter containing two notch pairs is:
1 1
𝐻𝑁𝑅1 (𝑢, 𝑣) = [ 2𝑛
][ ]
1 + [𝐷10 /𝐷1 (𝑢, 𝑣)] 1 + [𝐷10 /𝐷−1 (𝑢, 𝑣)]2𝑛
1 1
𝐻𝑁𝑅1 (40,60) = [ 4] [ ] = (0.9926)(0.2404) = 0.2386
20 20 4
1+[ ] 1+[ ]
68.01 15
1 1
𝐻𝑁𝑅2 (𝑢, 𝑣) = [ ] [ ]
1 + [𝐷20 /𝐷2 (𝑢, 𝑣)]2𝑛 1 + [𝐷10 /𝐷−2 (𝑢, 𝑣)]2𝑛
1 1
𝐻𝑁𝑅2 (40,60) = [ 4] [ 4] = (0.9759)(0.8078) = 0.7883
50 50
1+[ ] 1+[ ]
126.19 71.59
Example 22
Find the filter values of 〈𝑢, 𝑣〉 = 〈40,60〉 based on the Second order Butterworth notch
pass filter (BNRF) containing two notch pairs with 𝐷10 = 20 , 𝐷20 = 50 , 〈𝑢1 , 𝑣1 〉 =
〈20,35〉, and 〈𝑢2 , 𝑣2 〉 = 〈50,85〉?
Solution 22
The Butterworth notch pass filter containing two notch pairs is:
Example 1
What is the image response to the following Laplacian kernel for the following image?
21 10 20 1 −1 1
𝑓(𝑥, 𝑦) = [56 67 46] ℎ∇2 = [1 −8 1]
23 48 89 1 −1 1
Solution 1
89 23 48 89 23
20 21 10 20 21
46 56 67 46 56
89 23 48 89 23
20 21 10 20 21
Solution 2
The operator is the Laplacian operator. The output can be obtained using the following
1 |𝑅(𝑥, 𝑦)| ≥ 𝑇
𝑔(𝑥, 𝑦) = {
0 otherwise
where 𝑅(𝑥, 𝑦) is the image response to the Laplacian operator and 𝑇 is the threshold.
Example 3
Find the output for detecting isolated points using Laplacian kernel for the image of
Example 1 if 𝑇 = 70?
Solution 3
1 1 1
𝑔(𝑥, 𝑦) = [1 1 0]
1 0 1
Example 4
What are the filter masks for:
(a) Point detection?
(b) Horizontal line detection?
(c) 450 diagonal line detection?
(d) Vertical edge Sobel detection?
Solution 4
1 1 1 −1 −1 −1 −1 −1 +2 −1 0 1
ℎ𝑓 = [1 −8 1] ℎ𝑓 = [+2 +2 +2] ℎ𝑓 = [−1 +2 −1] ℎ𝑓 = [−2 0 2]
1 1 1 −1 −1 −1 +2 −1 −1 −1 0 1
(a) (b) (c) (d)
Example 5
Detect horizontal and vertical edges of 𝑓(𝑥, 𝑦) using Sobel gradient operators?
30 120 40 1 2 1 −1 0 1
𝑓(𝑥, 𝑦) = [50 130 30] ℎ𝑥 = [ 0 0 0] ℎ𝑦 = [−2 0 2]
45 150 37 −1 −2 −1 −1 0 1
Solution 5
37 45 150 37 45
40 𝟑𝟎 𝟏𝟐𝟎 𝟒𝟎 30 𝜕𝑓 +17 +42 +29
30 𝟓𝟎 𝟏𝟑𝟎 𝟑𝟎 50 = [−57 −72 −39]
37 𝟒𝟓 𝟏𝟓𝟎 𝟑𝟕 45 𝜕𝑥
+40 +30 +10
40 30 120 40 30
373 −08 −365 373.39 42.76 366.15
𝜕𝑓 𝜕𝑓 2 𝜕𝑓 2
= [393 −38 −355] ‖∇𝑓‖ = √( ) + ( ) = [397.11 81.41 357.14]
𝜕𝑦 𝜕𝑥 𝜕𝑦
406 −26 −380 407.97 39.70 380.13
Example 6
Detect horizontal and vertical edges of 𝑓(𝑥, 𝑦) using Prewitt gradient operators?
30 120 40 1 1 1 −1 0 1
𝑓(𝑥, 𝑦) = [50 130 30] ℎ1 = [ 0 0 0] ℎ2 = [−1 0 1]
45 150 37 −1 −1 −1 −1 0 1
Solution 6
37 45 150 37 45
40 𝟑𝟎 𝟏𝟐𝟎 𝟒𝟎 30 𝜕𝑓 +22 +22 +22
30 𝟓𝟎 𝟏𝟑𝟎 𝟑𝟎 50 = [−42 −42 −42]
37 𝟒𝟓 𝟏𝟓𝟎 𝟑𝟕 45 𝜕𝑥
+20 +20 +20
40 30 120 40 30
293 −18 −275 273.82 28.43 275.88
𝜕𝑓 𝜕𝑓 2 𝜕𝑓 2
= [293 −18 −275] √
‖∇𝑓‖ = ( ) + ( ) = [295.99 45.70 278.19]
𝜕𝑦 𝜕𝑥 𝜕𝑦
293 −18 −275 293.68 26.41 275.73
Example 7
(a) What is the differentiation of convolution property?
(b) What is the effect of differentiation of convolution property on the basic edge
detection?
Solution 7
𝑑 𝑑 𝑑
(a) (𝑓 ∗ 𝑔) = 𝑓 ∗ 𝑔= 𝑓∗𝑔
𝑑𝑥 𝑑𝑥 𝑑𝑥
(b) This property allows basic edge detection to save one operation by convolving 𝑓
directly with the derivative of Gaussian to get the result.
Example 8
Can you detect the edge of this line of an
image? If no, suggest a solution?
Solution 8
No because derivative respond strongly to noise. The solution is to smooth the image
before detecting the edge.
Example 9
What are the moving average values of the following image if 𝑛 = 3?
21 10 20
𝑓(𝑥, 𝑦) = [56 67 46]
23 48 89
Solution 9
The zigzag array of the matrix is:
Zigzag image 21 10 20 46 67 56 23 48 89