November 2018
Intermediate to advanced
492 pages
12h 19m
English
The following code block shows how to use scikit-image filters.rank module's morphological median filter. Some impulse noise is added to the input grayscale Lena image by randomly setting 10% of the pixels to 255 (salt) and another 10% to 0 (pepper). The structuring elements used are disks with different sizes in order to remove the noise with the median filter:
from skimage.filters.rank import medianfrom skimage.morphology import disknoisy_image = (rgb2gray(imread('../images/lena.jpg'))*255).astype(np.uint8)noise = np.random.random(noisy_image.shape)noisy_image[noise > 0.9] = 255noisy_image[noise < 0.1] = 0fig, axes = pylab.subplots(2, 2, figsize=(10, 10), sharex=True, sharey=True)axes1, axes2, axes3, ...Read now
Unlock full access