.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "advanced/image_processing/auto_examples/plot_sharpen.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_advanced_image_processing_auto_examples_plot_sharpen.py: Image sharpening ================= This example shows how to sharpen an image in noiseless situation by applying the filter inverse to the blur. .. GENERATED FROM PYTHON SOURCE LINES 8-34 .. image-sg:: /advanced/image_processing/auto_examples/images/sphx_glr_plot_sharpen_001.png :alt: plot sharpen :srcset: /advanced/image_processing/auto_examples/images/sphx_glr_plot_sharpen_001.png :class: sphx-glr-single-img .. code-block:: Python import scipy as sp import matplotlib.pyplot as plt f = sp.datasets.face(gray=True).astype(float) blurred_f = sp.ndimage.gaussian_filter(f, 3) filter_blurred_f = sp.ndimage.gaussian_filter(blurred_f, 1) alpha = 30 sharpened = blurred_f + alpha * (blurred_f - filter_blurred_f) plt.figure(figsize=(12, 4)) plt.subplot(131) plt.imshow(f, cmap="gray") plt.axis("off") plt.subplot(132) plt.imshow(blurred_f, cmap="gray") plt.axis("off") plt.subplot(133) plt.imshow(sharpened, cmap="gray") plt.axis("off") plt.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.538 seconds) .. _sphx_glr_download_advanced_image_processing_auto_examples_plot_sharpen.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sharpen.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_sharpen.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_sharpen.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_