A few fixes: give credit to scikit-learn guys, fix examples...

This commit is contained in:
Emmanuelle Gouillart
2011-09-24 15:05:16 +02:00
parent cce3d7bcc5
commit 4174d5fef0
6 changed files with 54 additions and 56 deletions
+5 -1
View File
@@ -44,7 +44,8 @@
Incorporating CellProfiler's Sobel edge detector, build and bug fixes.
- Emmanuelle Guillart
Total variation noise filtering
Total variation noise filtering, integration of CellProfiler's
mathematical morphology tools.
- Maël Primet
Total variation noise filtering
@@ -60,3 +61,6 @@
- Kyle Mandli
CSV to ReST code for feature comparison table.
- The Scikit Learn team
From whom we borrowed the example generation tools.
+2 -2
View File
@@ -21,7 +21,7 @@ from scipy import ndimage
import matplotlib.pyplot as plt
from scikits.image.filter import tv_denoise
l = scipy.lena()
l = scipy.misc.lena()
l = l[230:290, 220:320]
noisy = l + 0.4*l.std()*np.random.random(l.shape)
@@ -48,4 +48,4 @@ 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()
+43
View File
@@ -66,3 +66,46 @@ products or services of Licensee, or any third party.
8. By copying, installing or otherwise using matplotlib 0.98.3,
Licensee agrees to be bound by the terms and conditions of this
License Agreement.
The file
- gen_rst.py
was taken from the scikit-learn (http://scikit-learn.sourceforge.net), which
has the following license:
New BSD License
Copyright (c) 2007 - 2011 The scikit-learn developers.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
a. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
b. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
c. Neither the name of the Scikit-learn Developers nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.
+4 -2
View File
@@ -1,10 +1,12 @@
"""
Example generation for the scikit learn
Example generation for the scikit image.
Generate the rst files for the examples by iterating over the python
example files.
Files that generate images should start with 'plot'
Files that generate images should start with 'plot'.
This code was taken from the scikit-learn.
"""
import os
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

-51
View File
@@ -1,51 +0,0 @@
"""
====================================================
Denoising the picture of Lena using total variation
====================================================
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.
"""
import numpy as np
import scipy
from scipy import ndimage
import matplotlib.pyplot as plt
from scikits.image.filter import tv_denoise
l = scipy.lena()
l = l[230:290, 220:320]
noisy = l + 0.4*l.std()*np.random.random(l.shape)
tv_denoised = tv_denoise(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 = tv_denoise(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)