add comment to bilateral denoising example

This commit is contained in:
Olivier Debeir
2012-10-29 18:07:47 +01:00
parent a7ff15188f
commit d13517035f
3 changed files with 17 additions and 18 deletions
+9 -14
View File
@@ -1,26 +1,22 @@
"""
====================================================
Denoising the picture of Lena using total variation
Denoising the picture of Lena using bilateral filter
====================================================
In this example, we denoise a noisy version of the picture of Lena
using the total variation denoising filter. The result of this filter
is an image that has a minimal total variation norm, while being as
close to the initial image as possible. The total variation is the L1
norm of the gradient of the image, and minimizing the total variation
typically produces "posterized" images with flat domains separated by
sharp edges.
It is possible to change the degree of posterization by controlling
the tradeoff between denoising and faithfulness to the original image.
using an approximation of a bilateral filter.
The pixels used to compute a local mean respect these conditions:
- be close to the central pixel, i.e. belong to the given structuring element.
- have a similar gray level, similarity is fixed by an interval [-s0,+s1] centered on the central pixel gray level.
The filter used is an approximation of a classical bilateral filter in the sens that kernel are usually gaussian
both in spatial and spectral dimensions.
"""
import numpy as np
import matplotlib.pyplot as plt
from skimage import data, color, img_as_ubyte
from skimage.filter import tv_denoise
from skimage.rank import bilateral_mean
from skimage.morphology import disk
@@ -44,12 +40,11 @@ plt.axis('off')
plt.title('bilateral denoising', fontsize=20)
selem = disk(30)
bilateral_denoised = bilateral_mean(noisy.astype(np.uint8), selem=selem,s0=30,s1=30)
bilateral_denoised = bilateral_mean(noisy.astype(np.uint8), selem=selem,s0=40,s1=40)
plt.subplot(133)
plt.imshow(bilateral_denoised, cmap=plt.cm.gray, vmin=40, vmax=220)
plt.axis('off')
plt.title('(more) bilateral denoising', fontsize=20)
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9, bottom=0, left=0,
right=1)
plt.subplots_adjust(wspace=0.02, hspace=0.02, top=0.9, bottom=0, left=0,right=1)
plt.show()