0% found this document useful (0 votes)
2 views

Hw4 Solution

The document contains homework problems related to image processing, specifically addressing issues such as the effects of zero padding on image borders, averaging of pixel values, and the application of filters in the frequency domain. It includes mathematical formulations and derivations related to image transformations and the behavior of geometric and arithmetic means in image filtering. Additionally, it discusses the implications of repeated low-pass filtering and the nature of impulse responses in the context of image processing.

Uploaded by

hieule123pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Hw4 Solution

The document contains homework problems related to image processing, specifically addressing issues such as the effects of zero padding on image borders, averaging of pixel values, and the application of filters in the frequency domain. It includes mathematical formulations and derivations related to image transformations and the behavior of geometric and arithmetic means in image filtering. Additionally, it discusses the implications of repeated low-pass filtering and the nature of impulse responses in the context of image processing.

Uploaded by

hieule123pro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Homework # 4

CH. 4
Problem 22.
Unless all borders on of an image are black, padding the image with zeros introduces significant
discontinuities (edges) at one or more borders of the image. These can be strong horizontal and
vertical edges. These sharp transitions in the spatial domain introduce high-frequency
components along the vertical and horizontal axes of the spectrum.

Problem 23.
1
(a) 𝑓(̅ 𝑥, 𝑦) = 𝑀𝑁 ∑𝑀−1 𝑛−1
𝑥=0 ∑𝑦=0 𝑓(𝑥, 𝑦)
1 𝑄−1
𝑓̅𝑝 (𝑥, 𝑦) = 𝑃𝑄 ∑𝑃−1
𝑥=0 ∑𝑦=0 𝑓𝑝 (𝑥, 𝑦) ∵ Image is padded with zeros
1 𝑄−1
= 𝑃𝑄 ∑𝑃−1
𝑥=0 ∑𝑦=0 𝑓(𝑥, 𝑦)
1
= 𝑃𝑄 ∙ 𝑀𝑁 ∙ 𝑓 (̅ 𝑥, 𝑦)
𝑓̅ (𝑥,𝑦) 𝑃𝑄
∴ The ratio of average values of the original and padded images = ̅̅̅
= 𝑀𝑁
𝑓𝑝 (𝑥,𝑦)

(b) Yes
𝐹(0,0) = 𝑀𝑁𝑓 (̅ 𝑥, 𝑦), 𝐹𝑝 (0,0) = 𝑃𝑄𝑓̅𝑝 (𝑥, 𝑦)
𝑀𝑁
From (a), 𝑓̅𝑝 (𝑥, 𝑦) = 𝑃𝑄 𝑓 (̅ 𝑥, 𝑦)

𝐹𝑝 (0,0) 𝑀𝑁 𝐹(0,0)
→ =
𝑃𝑄 𝑃𝑄 𝑀𝑁

∴ 𝐹𝑝 (0,0) = 𝐹(0,0)

Problem 26.
𝜕2 𝑓(𝑡,𝑧) 𝜕2 𝑓(𝑡,𝑧)
(a) ∇2 𝑓(𝑡, 𝑧) = +
𝜕𝑡 2 𝜕𝑧 2

Let’s begin with one variable.


𝑑𝑓(𝑧) ∞ 𝑑𝑓(𝑧) −𝑗2𝜋𝜈𝑧
𝐹[ ] = ∫−∞ 𝑒 𝑑𝑧
𝑑𝑧 𝑑𝑧

= 𝑓(𝑧)𝑒 −𝑗2𝜋𝜈𝑧 ]∞
−∞ − ∫−∞ 𝑓(𝑧)(−𝑗2𝜋𝜈) 𝑒
−𝑗2𝜋𝜈𝑧
𝑑𝑧

= (𝑗2𝜋𝜈) ∫−∞ 𝑓(𝑧)𝑒 −𝑗2𝜋𝜈𝑧 𝑑𝑧
= (𝑗2𝜋𝜈)𝐹(𝜈)
Consider the second derivative.
𝑑𝑓(𝑧)
Let’s define 𝑔(𝑧) = 𝑑𝑧

𝑑𝑔(𝑧)
𝐹[ ] = (𝑗2𝜋𝜈)𝐺(𝜈)
𝑑𝑧

𝑑𝑓(𝑧)
→ 𝑔(𝑧) = → 𝐺(𝜈) = (𝑗2𝜋𝜈)𝐹(𝜈)
𝑑𝑧

𝑑2 𝐹(𝑧)
∴ 𝐹[ ] = (𝑗2𝜋𝜈)2 𝐹(𝜈)
𝑑𝑧 2

Consider 2D derivative.
𝜕2 𝑓(𝑡,𝑧)
𝐹[ ] = (𝑗2𝜋𝜇)2 𝐹(𝜇, 𝜈)
𝑑𝑡 2

𝜕2 𝑓(𝑡,𝑧)
𝐹[ ] = (𝑗2𝜋𝜈)2 𝐹(𝜇, 𝜈)
𝑑𝑧 2

𝜕2 𝑓(𝑡,𝑧) 𝜕2 𝑓(𝑡,𝑧)
→ 𝐹[∇2 𝑓(𝑡, 𝑧)] = 𝐹 [ ]+ 𝐹[ ]
𝑑𝑡 2 𝑑𝑧 2
= (𝑗2𝜋𝜇)2 𝐹(𝜇, 𝜈) + (𝑗2𝜋𝜈)2 𝐹(𝜇, 𝜈)
= −4𝜋 2 (𝜇 2 + 𝜈 2 )𝐹(𝜇, 𝜈)
(b) We can generate a filter for using with the DFT simply by sampling
𝐻(𝑢, 𝑣) = −4𝜋 2 (𝑢2 + 𝜈 2 )
𝑀 2 𝑁 2
→ 𝐻(𝑢, 𝑣) = −4𝜋 2 ([𝑢 − 2 ] + [𝜈 − 2 ] )

We have the following Fourier transform pair relating the Laplacian in the spatial and
frequency domains:
𝑀 2 𝑁 2
𝛻 2 𝑓(𝑥, 𝑦) ⇔ −4𝜋 2 ([𝑢 − 2 ] + [𝜈 − 2 ] ) 𝐹(𝑢, 𝜈)

→ The filter is a sampled version of a continuous function.


Problem 27.
(a) The spatial average:
1
𝑔(𝑥, 𝑦) = [𝑓(𝑥, 𝑦 − 2) + 𝑓(𝑥, 𝑦 − 1) + 𝑓(𝑥, 𝑦 + 1) + 𝑓(𝑥, 𝑦 + 2) + 𝑓(𝑥 − 1, 𝑦)
12
+ 𝑓(𝑥 − 2, 𝑦) + 𝑓(𝑥 + 1, 𝑦) + 𝑓(𝑥 + 2, 𝑦) + 𝑓(𝑥 + 1, 𝑦 + 1)
+ 𝑓(𝑥 − 1, 𝑦 + 1) + 𝑓(𝑥 + 1, 𝑦 − 1) + 𝑓(𝑥 − 1, 𝑦 − 1)]
Following the property 3 in Table 4.3:
1 −𝑗4𝜋𝜈 𝑗2𝜋𝜈 𝑗2𝜋𝜈 𝑗4𝜋𝜈 𝑗2𝜋𝑢 𝑗4𝜋𝑢 𝑗2𝜋𝑢 𝑗4𝜋𝑢
𝐺(𝑢, 𝜈) = [𝑒 𝑁 + 𝑒 − 𝑁 + 𝑒 𝑁 + 𝑒 𝑁 + 𝑒 − 𝑀 + 𝑒 − 𝑀 + 𝑒 𝑀 + 𝑒 𝑀
12
𝑢 𝜈 𝑢 𝜈 𝑢 𝜈 𝑢 𝜈
+ 𝑒 𝑗2𝜋(𝑀+𝑁) + 𝑒 𝑗2𝜋(−𝑀+𝑁) + 𝑒 𝑗2𝜋(𝑀−𝑁) + 𝑒 −𝑗2𝜋(𝑀+𝑁) ] ∙ 𝐹(𝑢, 𝜈)
1 4𝜋𝜈 2𝜋𝜈 4𝜋𝑢 2𝜋𝑢 𝑢 𝜈
= [cos ( ) + cos ( ) + cos ( ) + cos ( ) + cos {2𝜋 ( + )}
6 𝑁 𝑁 𝑀 𝑀 𝑀 𝑁
𝑢 𝜈
+ cos {2𝜋 ( − )}] ∙ 𝐹(𝑢, 𝜈)
𝑀 𝑁
= 𝐻(𝑢, 𝜈) ∙ 𝐹(𝑢, 𝜈)
1 4𝜋𝜈 2𝜋𝜈 4𝜋𝑢 2𝜋𝑢 𝑢 𝜈
∴ 𝐻(𝑢, 𝜈) = [cos ( ) + cos ( ) + cos ( ) + cos ( ) + cos {2𝜋 ( + )}
6 𝑁 𝑁 𝑀 𝑀 𝑀 𝑁
𝑢 𝜈
+ cos {2𝜋 ( − )}]
𝑀 𝑁
2𝜋𝑢 2𝜋(𝑢−𝑀/2)
(b) Express all the cosine terms as centered function: cos ( ) = cos [ ]
𝑀 𝑀

2𝜋(𝑢−𝑀/2)
As u ranges from 0 to M, the value of cos [ ] starts at -1, peak at 1 when 𝑢 =
𝑀
𝑀/2 (the center), and then again decreases to -1 when 𝑢 = 𝑀.
Thus, the amplitude response of the filter decreases as a function of the distance from the
origin of the centered filter, which is nothing but a low-pass filter.

Problem 37.
2 (𝑢,𝑣)/2𝐷2
(a) One application of the filter gives: 𝐺(𝑢, 𝜈) = 𝐻(𝑢, 𝜈)𝐹(𝑢, 𝜈) = 𝑒 −𝐷 0 ∙ 𝐹(𝑢, 𝜈)
2 (𝑢,𝑣)/2𝐷2
Similarly, k applications of the filter would give: 𝐺𝑘 (𝑢, 𝜈) = 𝑒 −𝑘𝐷 0 ∙ 𝐹(𝑢, 𝜈)
The inverse DFT of the 𝐺𝑘 (𝑢, 𝜈) would give the image resulting from k passes of the
Gaussian filter. If k is “large enough”, the Gaussian LPF will become a notch pass filter,
passing only 𝐹(0,0). We know that this term is equal to the average value of the image. So,
there is a value of k after which the result of repeated low-pass filtering will simply produce
a constant image. The value of all pixels on this image will be equal to the value of the
original image. Note that the answer applies even as k approaches infinity. In this case, the
filter will approach an impulse at the origin, and this would still give us 𝐹(0,0) as the result
of filtering.
CH. 5
Problem 1.

Problem 2.

Problem 10.
(a) Geometric mean is 0 whenever any pixel is 0.
The geometric mean will give only values of 0 and 1, whereas the arithmetic mean will give
intermedia values (blurred).
(b) Black is 0, so the geometric mean will return values of 0 as long as at least one pixel in the
window is black. Because the center of the mask can be outside the original black area
when this happens, the figure will be thickened.

Problem 16.

𝑔(𝑥, 𝑦) = ∭ 𝑓(𝛼, 𝛽)ℎ(𝑥 − 𝛼, 𝑦 − 𝛽)𝑑𝛼𝑑𝛽
−∞

Given that 𝑓(𝛼, 𝛽) = 𝛿(𝛼 − 𝑎, 𝛽 − 𝑏),



𝑔(𝑥, 𝑦) = ∭ 𝛿(𝛼 − 𝑎, 𝛽 − 𝑏)ℎ(𝑥 − 𝛼, 𝑦 − 𝛽)𝑑𝛼𝑑𝛽
−∞

2 +(𝑦−𝛽)2 ]
= ∭ 𝛿(𝛼 − 𝑎, 𝛽 − 𝑏)𝑒 −[(𝑥−𝛼) 𝑑𝛼𝑑𝛽
−∞

The integral of the impulse is nonzero only when (𝑥 = 𝛼, 𝑦 = 𝛽).

Problem 17.
The components of motion are as follows:
𝑎𝑡
0 ≤ 𝑡 ≤ 𝑇1
𝑥0 (𝑡) = { 𝑇1
𝑎 𝑇1 ≤ 𝑡 ≤ 𝑇1 + 𝑇2

and
0 0 ≤ 𝑡 ≤ 𝑇1
𝑦0 (𝑡) = {𝑏(𝑡 − 𝑇1 )
𝑇1 ≤ 𝑡 ≤ 𝑇1 + 𝑇2
𝑇1
𝑇1 𝑇1 +𝑇2
𝐻(𝑢, 𝑣) = ∫ 𝑒 −𝑗2𝜋[𝑢𝑎𝑡/𝑇1] 𝑑𝑡 + ∫ 𝑒 −𝑗2𝜋[𝑢𝑎+𝑣𝑏(𝑡−𝑇1)/𝑇2] 𝑑𝑡
0 𝑇1

𝑇1 +𝑇2
𝑇1
= sin(𝜋𝑢𝑎) 𝑒 −𝑗𝜋𝑢𝑎 + 𝑒 −𝑗2𝜋𝑢𝑎 ∫ 𝑒 −𝑗2𝜋𝑣𝑏(𝑡−𝑇1)/𝑇2 𝑑𝑡
𝜋𝑢𝑎 𝑇1

𝑇2
𝑇1 −𝑗𝜋𝑢𝑎 −𝑗2𝜋𝑢𝑎
= sin(𝜋𝑢𝑎) 𝑒 +𝑒 ∫ 𝑒 −𝑗2𝜋𝑣𝑏𝜏/𝑇2 𝑑𝜏
𝜋𝑢𝑎 0

𝑇1 𝑇2
= sin(𝜋𝑢𝑎) 𝑒 −𝑗𝜋𝑢𝑎 + 𝑒 −𝑗2𝜋𝑢𝑎 sin (𝜋𝑣𝑏)𝑒 −𝑗𝜋𝑣𝑏
𝜋𝑢𝑎 𝜋𝑣𝑏

MATLAB task
clear; close all;
load hw4.mat;

% display original and noisy images


figure; imshow(p, []);
figure; imshow(pn, []);

% apply 3x3 mean filter


h_mean = ones(3,3)/9;
p_mean = filter2(h_mean,pn, 'same');
figure; imshow(p_mean, []);
% apply alpha trimmed medan filter 3x3 with d=2,4,6
p_trim = zeros(size(p));
d = 2;
for i = 2:size(pn,1)-1
for j = 2:size(pn,2)-1
inten_array = pn(i-1:i+1, j-1:j+1);
sorted_inten = sort(inten_array(:));
sorted_removed_inten = sorted_inten(1+d/2:end-d/2);
p_trim(i,j) = mean(sorted_removed_inten);
end
end
figure; imshow(p_trim, []);
<Original image> <Noisy image>

<Mean filtering> <Adaptive mean filtering with d=2>

<Adaptive mean filtering with d=4> <Adaptive mean filtering with d=6>

The image is much blurred as d increases

You might also like