(0,0) underlined:
0
5
0
7
5
6
5
7
3
3
0
1
3
4
5
1
6
2
5
2
3
2
6
5
4
1. compute the binomial 3x3 filter and the result of the filtered image for the pixel
at location (2,2)
2. compute, for the same location (2,2), the result of image filtering by the 3x3
median filter
3. same question but for the following weighted median filter:
2
3
2
3
5
3
2
3
2
2
6
7
3
3
2
1
3
4
5
1
2
2
5
6
3
2
2
5
7
ANSWERS:
1. the binomial 5x5 filter has the following mask:
1/16*
1
2
1
2
4
2
1
2
1
location (2,2) is the center of the image and the result of filtering is given by the 2D
convolution operation. the neighborhood considered is:
5
1
6
7
3
2
3
4
5
and the result: (1*5+2*1+1*6+2*7+4*3+2*2+1*3+2*4+1*5)/16 =
(5+2+6+14+12+4+3+8+5)/16=59/16=3.68if the result remains on 3 bits and in
the same range we round to the nearest integer in the 0-7 range so the final result
is 4.
2. the median filter constructs the sequence of values in the specified
neighborhood. the sequence is sorted and the result is represented by the median
value (value at the center of the sorted sequence):
the neighborhood:
5
1
7
3
3
4
unsorted sequence: 5,1,6,7,3,2,3,4,5
6
2
5
1
3
4
6
2
5
1
6
3
2
4
5
considered for the mean computation are those in
cos ( ) sin( ) 0
yout
1 0 2
6
6
1 0 2
yin
=
xout
0 1 2
0 1 2 xin
sin ( ) cos ( ) 0
1
0 0 1
0 0 1
1
6
6
0
0
1
( )( )
)(
)( )
yin=2.5
{xin=1.1
this means that the value of the rotated image at location (1,2) is the same as the
value of the original image at location (1.1,2.5)
the problem is that these are not integer coordinates so we will use interpolation to
estimate a value at the non integer location
bilinear interpolation considers the 4 neighbors to estimate a value at the non
integer location:
f(x,y) =a*b*f([x]+1,[y]+1) + (1-a)*b*f([x],[y] +1) + a*(1-b)*f([x]+1,[y]) + (1-a)*(1b)*f([x],[y])
where: [] is the integer part, a and b are the fractional parts of x respectively y; f is
the image value.
in our case:
5
1
7
3
f(1.1,2.5) = 0.1*0.5*f(2,3)+0.9*0.5*f(1,3)+0.1*0.5*f(2,2)+0.9*0.5*f(1,2)=
0
0
0
1
0
-1
-1
-2
-1
2
0
-2
1
0
-1
1
3
4
6
2
5
gx = 1*5+2*7+1*3-1*6-2*2-1*5=5+14+3-6-4-5=7
gy = 1*5+2*1+1*6-1*3-2*4-1*5 = 5+2+6-3-8-5 = -3
Sobel gradient magnitude: g=sqrt(gx*gx+gy*gy)=sqrt(49+9)=sqrt(58)=7.6 ~ 8
direction of the gradient: atan(gy/gx) = atan(-3/7)=......
8. we start by choosing an arbitrary threshold in the image range: 0-7. for example
the starting threshold = 3.5 (the middle of the image range)
original image
7
7
6
7
1
2
6
7
3
3
2
1
3
4
7
1
2
2
5
6
3
2
2
7
7
we compute the means of the pixels having values bigger (mb) respectively smaller
(ms) than the threshold
image pixels bigger that the threshold: 7,7,6,6,7,7,4,5,7,7,6,7=> mb=76/12 = 6.33
image pixels smaller that the threshold:2,2,1,3,1,2,2,3,2,2,3,1,3 = 27/13 =2.07
0
1
1
0
0
0
0
0
0
1
0
0
0
1
1
0
0
0
1
1