.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_intro_scipy_auto_examples_plot_image_filters.py: ========================= Plot filtering on images ========================= Demo filtering for denoising of images. .. image:: /intro/scipy/auto_examples/images/sphx_glr_plot_image_filters_001.png :class: sphx-glr-single-img .. code-block:: python # Load some data from scipy import misc face = misc.face(gray=True) face = face[:512, -512:] # crop out square on right # Apply a variety of filters from scipy import ndimage from scipy import signal from matplotlib import pyplot as plt import numpy as np noisy_face = np.copy(face).astype(np.float) noisy_face += face.std() * 0.5 * np.random.standard_normal(face.shape) blurred_face = ndimage.gaussian_filter(noisy_face, sigma=3) median_face = ndimage.median_filter(noisy_face, size=5) wiener_face = signal.wiener(noisy_face, (5, 5)) plt.figure(figsize=(12, 3.5)) plt.subplot(141) plt.imshow(noisy_face, cmap=plt.cm.gray) plt.axis('off') plt.title('noisy') plt.subplot(142) plt.imshow(blurred_face, cmap=plt.cm.gray) plt.axis('off') plt.title('Gaussian filter') plt.subplot(143) plt.imshow(median_face, cmap=plt.cm.gray) plt.axis('off') plt.title('median filter') plt.subplot(144) plt.imshow(wiener_face, cmap=plt.cm.gray) plt.title('Wiener filter') plt.axis('off') plt.subplots_adjust(wspace=.05, left=.01, bottom=.01, right=.99, top=.99) plt.show() **Total running time of the script:** ( 0 minutes 0.382 seconds) .. _sphx_glr_download_intro_scipy_auto_examples_plot_image_filters.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_image_filters.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_image_filters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_