Professional Documents
Culture Documents
Solutions to Exercise 2.
1. (a) Zero padding of the borders:
0
0
0
0
0
0
0
1
5
1
2
0
0
2
2
1
4
0
0
4
5
3
6
0
0
5
2
6
7
0
0
0
0
0
0
0
1 1 1
1
wa = 1 1 1 .
9
1 1 1
All the pixels are scanned from left to right and from up to down.
The added zero pixels on the borders are not processed.
g(0, 0) = 1/9 (0 + 0 + 0 + 0 + 1 + 2 + 0 + 5 + 2)
= 10/9 = 1.111 . . . 1
g(0, 1) = 1/9 (0 + 0 + 0 + 1 + 2 + 4 + 5 + 2 + 5)
= 19/9 = 2.111 . . . 2
..
.
The resulting filtered image:
1
1
2
1
2
3
3
2
2
3
4
3
1 2
1
wb =
2 4
16
1 2
2
3
3
2
are scanned as in part (a),
2 .
1
g(0, 0) = 1/16 (1 0 + 2 0 + 1 0 + 2 0 + 4 1
+2 2 + 1 0 + 2 5 + 1 2)
= 20/16 = 1.25 1
1
g(0, 1) = 1/16 (1 0 + 2 0 + 1 0 + 2 1 + 4 2
+2 4 + 1 5 + 2 2 + 1 5)
= 32/16 = 2
..
.
The resulting filtered image:
1
2
2
1
2
3
3
2
3
4
4
4
2
3
4
3
2
2
1
4
4
5
3
6
5
2
6
7
3
4
Note that the resulting image is smaller than the input image due
to the selected border handling.
(d) Reflecting the border pixels
1
1
5
1
2
2
1
1
5
1
2
2
2
2
2
1
4
4
4
4
5
3
6
6
5
5
2
6
7
7
5
5
2
6
7
7
0 1 0
wd = 1 4 1 .
0 1 0
g(0, 0) = 0 1 + 1 1 + 0 2 + 1 1 4 1 + 1 2 +
05+15+02=5
g(0, 1) = 0 1 + 1 2 + 0 4 + 1 1 4 2 + 1 4 +
05+12+05=1
..
.
The resulting image:
5
-11
5
1
1
5
6
-3
0
-9
6
-4
-4
10
-6
-2
3 X
3
1 X
f (x, y)ej2(ux/4+vy/4) ,
16 x=0 y=0
0 u 3, 0 v 3
and
F (0, 0) =
=
F (0, 1) =
3 X
3
1 X
f (x, y)ej2(0x/4+0y/4)
16 x=0 y=0
1
(1 + 0 + 0 + 0 + . . . + 2 + 1) = 4/16
16
3 X
3
1 X
f (x, y)ej2(0x/4+1y/4)
16 x=0 y=0
3
1
(1ej210/4 + 2ej212/4 + 1ej212/4
16
1
2
(1 + 2(1) + 1(1)) =
16
16
=
=
..
.
3 X
3
1 X
f (x, y)ej2(1x/4+3y/4)
16 x=0 y=0
F (1, 3) =
1
(1ej2(10/4+30/4) + 2ej2(11/4+32/4)
16
+1ej2(12/4+32/4) )
1
1 1
=
(1 + 2j + 1) = + j
16
8 8
..
.
F (u, v) =
2
1
2
1
j 1 + j j 1 + j
0
1
0
1
j 1j j 1j
(b) Separability of the 2-D Fourier transform means that we can get
the full 2-D transform by applying 1-D transform twice. First
we apply the 1-D transform to rows and then to columns of the
image (or vice versa).
Let us compute an intermediate image F (x, v) by applying 1-D
DFT to rows of the input image f (x, y)
1
1 NX
F (x, v) =
f (x, y)ej2vy/N .
N y=0
3
1X
f (x, y)ej2vy/4 , 0 x 3, 0 v 3
4 y=0
F (0, 0) =
3
1X
1
f (0, y)ej20y/4 = (1 + 0 + 0 + 0)
4 y=0
4
..
.
F (1, 3) =
=
3
1X
f (1, y)ej23y/4
4 y=0
1 j230/4
(0e
+ 0ej231/4 + 2ej232/4
4
4
+0ej233/4 =
1
2
..
.
The resulting intermediate image F (x, v):
F (x, v) =
4
1 1 1 1
2 2 2 2
1 1 1 1
0 0 0 0
3
1X
F (x, v)ej2ux/4 , 0 u 3, 0 v 3
4 x=0
F (0, 0) =
3
1X
1 1
F (x, 0)ej20x/4 = (1 + 2 + 1 + 0) = 4/16
4 x=0
4 4
..
.
F (1, 3) =
3
1X
1 1
F (x, 3)ej21x/4 = (1ej210/4 +
4 x=0
4 4
F (u, v) =
2
1
2
1
j 1 + j j 1 + j
0
1
0
1
j 1j j 1j
3. Image filtering in frequency space is done by element-wise multiplication of the frequcency domain represenations of the image and the
filter.
G(u, v) = F (u, v)H(u, v)
2
1
2
1
j 1 + j j 1 + j
0
1
0
1
j 1j j 1j
32
1
4
2
0
0
0
1
0
0
0
4 1 0 1
0 0 0 0
0 0 0 0
0 0 0 0
1
M
1 N
X
X
u=0 v=0
16
1
1
1
1
2
2
2
2
3
3
3
3
2
2
2
2
0
0
0
0
1
0
0
0