.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_advanced_image_processing_auto_examples_plot_face_tv_denoise.py: Total Variation denoising =========================== This example demoes Total-Variation (TV) denoising on a Racoon face. .. image:: /advanced/image_processing/auto_examples/images/sphx_glr_plot_face_tv_denoise_001.png :class: sphx-glr-single-img .. code-block:: python import numpy as np import scipy import scipy.misc import matplotlib.pyplot as plt try: from skimage.restoration import denoise_tv_chambolle except ImportError: # skimage < 0.12 from skimage.filters import denoise_tv_chambolle f = scipy.misc.face(gray=True) f = f[230:290, 220:320] noisy = f + 0.4*f.std()*np.random.random(f.shape) tv_denoised = denoise_tv_chambolle(noisy, weight=10) plt.figure(figsize=(12, 2.8)) plt.subplot(131) plt.imshow(noisy, cmap=plt.cm.gray, vmin=40, vmax=220) plt.axis('off') plt.title('noisy', fontsize=20) plt.subplot(132) plt.imshow(tv_denoised, cmap=plt.cm.gray, vmin=40, vmax=220) plt.axis('off') plt.title('TV denoising', fontsize=20) tv_denoised = denoise_tv_chambolle(noisy, weight=50) plt.subplot(133) plt.imshow(tv_denoised, cmap=plt.cm.gray, vmin=40, vmax=220) plt.axis('off') plt.title('(more) TV denoising', fontsize=20) plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9, bottom=0, left=0, right=1) plt.show() **Total running time of the script:** ( 0 minutes 0.386 seconds) .. _sphx_glr_download_advanced_image_processing_auto_examples_plot_face_tv_denoise.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: plot_face_tv_denoise.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_face_tv_denoise.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_