November 2018
Intermediate to advanced
492 pages
12h 19m
English
The following code shows how to use the MaxFilter()to remove the pepper noise followed by a MinFilter() to remove the salt noise from an image:
im = Image.open('../images/mandrill_spnoise_0.1.jpg')pylab.subplot(1,3,1)plot_image(im, 'Original Image with 10% added noise')im1 = im.filter(ImageFilter.MaxFilter(size=sz)) pylab.subplot(1,3,2), plot_image(im1, 'Output (Max Filter size=' + str(sz) + ')') im1 = im1.filter(ImageFilter.MinFilter(size=sz)) pylab.subplot(1,3,3), plot_image(im1, 'Output (Min Filter size=' + str(sz) + ')', size=15) pylab.show()
The following screenshot shows the output of the previous code block. It can be seen that the maximum and minimum filters are somewhat effective in removing the salt-and-pepper ...
Read now
Unlock full access