.. _example_decomposition_plot_image_denoising.py: ========================================= Image denoising using dictionary learning ========================================= An example comparing the effect of reconstructing noisy fragments of Lena using online :ref:`DictionaryLearning` and various transform methods. The dictionary is fitted on the non-distorted left half of the image, and subsequently used to reconstruct the right half. A common practice for evaluating the results of image denoising is by looking at the difference between the reconstruction and the original image. If the reconstruction is perfect this will look like gaussian noise. It can be seen from the plots that the results of :ref:`omp` with two non-zero coefficients is a bit less biased than when keeping only one (the edges look less prominent). It is in addition closer from the ground truth in Frobenius norm. The result of :ref:`least_angle_regression` is much more strongly biased: the difference is reminiscent of the local intensity value of the original image. Thresholding is clearly not useful for denoising, but it is here to show that it can produce a suggestive output with very high speed, and thus be useful for other tasks such as object classification, where performance is not necessarily related to visualisation. .. rst-class:: horizontal * .. image:: images/plot_image_denoising_4.png :scale: 47 * .. image:: images/plot_image_denoising_5.png :scale: 47 * .. image:: images/plot_image_denoising_2.png :scale: 47 * .. image:: images/plot_image_denoising_1.png :scale: 47 * .. image:: images/plot_image_denoising_3.png :scale: 47 * .. image:: images/plot_image_denoising_6.png :scale: 47 **Script output**:: Distorting image... Extracting clean patches... done in 0.22s. Learning the dictionary... done in 7.92s. Extracting noisy patches... done in 0.42s. Orthogonal Matching Pursuit 1 atom ... done in 4.63s. Orthogonal Matching Pursuit 2 atoms ... done in 7.26s. Least-angle regression 5 atoms ... done in 35.54s. Thresholding alpha=0.1 ... done in 0.83s. **Python source code:** :download:`plot_image_denoising.py ` .. literalinclude:: plot_image_denoising.py :lines: 30-