
324 A Computational Introduction to Digital Image Processing, Second Edition
MATLAB/Octave
>> for i = 1:256,
> for j = 1:256,
> c2(i+1,j+1) =
min
(min(c2(i:i+2,j:j+2)+fmask));
> end
> end
>> for i = 256:-1:1,
> for j = 256:-1:1,
> c2(i+1,j+1) = min(min(c2(i:i+2,j:j+2)+bmask));
> end
> end
or in Python with
Python
In : for i in range(256):
...: for j in range(256):
...: c2[i+1,j+1] = (c2[i:i+3,j:j+3]+fmask).min()
...:
In : for i in range(256)[::-1]:
...: for j in range(256)[::-1]:
...: c2[i+1,j+1] = (c2[i:i+3,j:j+3]+bmask).min()
...:
The result can be shown as
MATLAB/Octave
>> imshow(mat2gray(2(2:257,2:257)))
or
Python
In : io.imshow(c2[1:257,1:257])
and is shown in Figure ...