
Neighborhood Processing 105
An alternative derivation is to write the equation relating s and k as
s −
s
k
= 1.
If s /k = t, say, then s = t + 1. So if s/k = 2/3, then s = 5/3 and so the filter is
5
3
0 0 0
0 1 0
0 0 0
−
2
3
1
9
1 1 1
1 1 1
1 1 1
=
1
27
−2 −2 −2
−2 43 −2
−2 −2 −2
For example, consider an image of an iconic Australian animal:
MATLAB/Octave
>> k = imread(’koala.png’);
The first filter above can be constructed as
MATLAB/Octave
>> id = [0 0 0;0 1 0;0 0 0];
>> f = fspecial(’average’);
>> u = 3
*
id - 2
*
f
u =
-0.22222 -0.22222 -0.22222
-0.22222 2.77778 -0.22222
-0.22222 -0.22222 -0.22222
and applied to the image in the usual way:
MATLAB/Octave
>> ku = imfilter(k,u); ...