
Neighborhood Processing 95
So to obtain, for example, the image in Figure 5.6(c), you could use the following Python
commands:
Python
In: c = io.imread(’cameraman.png’)
In: cf = ndi.convolve(c,ones((9,9))/81,mode=’constant’)
In: io.imshow(cfs)
Alternately, you could use the built in uniform
_
filter f unction:
Python
In:
cf = ndi.uniform
_
filter(c,[9,9],mode=’constant’)
Python differs from MATLAB and Octave here in that the default behavior of spatial
convolution at the edges of the image is to reflect the image in all its edges. This will
ameliorate the dark borders seen in Figure 5.6. So with leaving the
mode parameter in its
default setting, the commands
Python ...