November 2018
Intermediate to advanced
492 pages
12h 19m
English
The following code block shows how gray-level opening and closing can remove salt-and-pepper noise from a grayscale image, and how the successive application of opening and closing removes salt-and-pepper (impulse) noise from the input, a noisy mandrill grayscale image:
from scipy import ndimageim = rgb2gray(imread('../images/mandrill_spnoise_0.1.jpg'))im_o = ndimage.grey_opening(im, size=(2,2))im_c = ndimage.grey_closing(im, size=(2,2))im_oc = ndimage.grey_closing(ndimage.grey_opening(im, size=(2,2)), size=(2,2))pylab.figure(figsize=(20,20))pylab.subplot(221), pylab.imshow(im), pylab.title('original', size=20), pylab.axis('off')pylab.subplot(222), pylab.imshow(im_o), pylab.title('opening (removes ...Read now
Unlock full access