From ecba2df2ac60b636f10158a93da0aa480e02d333 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Sat, 20 Apr 2013 19:45:21 +0200 Subject: [PATCH 1/5] median filter outlier --- skimage/filter/ctmf.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/skimage/filter/ctmf.py b/skimage/filter/ctmf.py index 94f273e1..45c387b5 100644 --- a/skimage/filter/ctmf.py +++ b/skimage/filter/ctmf.py @@ -42,6 +42,13 @@ def median_filter(image, radius=2, mask=None, percent=50): not overlap the mask, the filtered result is underfined, but in practice, it will be the lowest value in the valid area. + Examples + -------- + >>> a = np.ones((5, 5)) + >>> a[2, 2] = 10 # introduce outlier + >>> b = filter.median_filter(a) + >>> b[2, 2] # the median filter is good at removing outliers + 1.0 ''' if image.ndim != 2: From 3f47aefa908ab88d60e95b6d4c4c67f93a5f7002 Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Sat, 20 Apr 2013 19:53:58 +0200 Subject: [PATCH 2/5] histogram example --- skimage/exposure/exposure.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index c7f1e712..10d2427d 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -14,6 +14,7 @@ __all__ = ['histogram', 'cumulative_distribution', 'equalize', def histogram(image, nbins=256): """Return histogram of image. + Unlike `numpy.histogram`, this function returns the centers of bins and does not rebin integer arrays. For integer arrays, each integer value has its own bin, which improves speed and intensity-resolution. @@ -32,6 +33,14 @@ def histogram(image, nbins=256): The values of the histogram. bin_centers : array The values at the center of the bins. + + Examples + -------- + >>> camera = skimage.data.camera() + >>> hi = exposure.histogram(camera) + >>> # Plot histogram + >>> import matplotlib.pyplot as plt + >>> plt.plot(hi[1], hi[0]) """ # For integer types, histogramming with bincount is more efficient. From 8efaaee3c8a78b10828775d678c394f00ad9b98b Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Sat, 20 Apr 2013 20:09:45 +0200 Subject: [PATCH 3/5] Find contours example --- skimage/measure/find_contours.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/skimage/measure/find_contours.py b/skimage/measure/find_contours.py index 3a546ccf..4a7a6bbf 100755 --- a/skimage/measure/find_contours.py +++ b/skimage/measure/find_contours.py @@ -95,6 +95,17 @@ def find_contours(array, level, Resolution 3D Surface Construction Algorithm. Computer Graphics (SIGGRAPH 87 Proceedings) 21(4) July 1987, p. 163-170). + Examples + -------- + >>> a = np.zeros((3, 3)) + >>> a[0, 0] = 1 + >>> a + array([[ 1., 0., 0.], + [ 0., 0., 0.], + [ 0., 0., 0.]]) + >>> measure.find_contours(a, 0.5) + [array([[ 0. , 0.5], + [ 0.5, 0. ]])] """ array = np.asarray(array, dtype=np.double) if array.ndim != 2: From 5123692f453956d33478044347d09e9c48f6651a Mon Sep 17 00:00:00 2001 From: Emmanuelle Gouillart Date: Tue, 23 Apr 2013 23:56:07 +0200 Subject: [PATCH 4/5] Blank lines in reconstruction docstring for nicer display --- skimage/morphology/greyreconstruct.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/skimage/morphology/greyreconstruct.py b/skimage/morphology/greyreconstruct.py index 09d3c9e6..049488f8 100644 --- a/skimage/morphology/greyreconstruct.py +++ b/skimage/morphology/greyreconstruct.py @@ -60,13 +60,15 @@ def reconstruction(seed, mask, method='dilation', selem=None, offset=None): >>> import numpy as np >>> from skimage.morphology import reconstruction - First, we create a sinusoidal mask image w/ peaks at middle and ends. + First, we create a sinusoidal mask image with peaks at middle and ends. + >>> x = np.linspace(0, 4 * np.pi) >>> y_mask = np.cos(x) Then, we create a seed image initialized to the minimum mask value (for reconstruction by dilation, min-intensity values don't spread) and add "seeds" to the left and right peak, but at a fraction of peak value (1). + >>> y_seed = y_mask.min() * np.ones_like(x) >>> y_seed[0] = 0.5 >>> y_seed[-1] = 0 From f2ace7536992a2bec24150682958f9ba6bfc82aa Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 25 Apr 2013 23:13:41 -0500 Subject: [PATCH 5/5] Fixes to make doctests pass. --- skimage/exposure/exposure.py | 8 ++++---- skimage/filter/ctmf.py | 2 +- skimage/measure/find_contours.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index 10d2427d..6f2066aa 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -36,11 +36,11 @@ def histogram(image, nbins=256): Examples -------- - >>> camera = skimage.data.camera() - >>> hi = exposure.histogram(camera) - >>> # Plot histogram + >>> from skimage import data + >>> hist = histogram(data.camera()) >>> import matplotlib.pyplot as plt - >>> plt.plot(hi[1], hi[0]) + >>> plt.plot(hist[1], hist[0]) # doctest: +ELLIPSIS + [...] """ # For integer types, histogramming with bincount is more efficient. diff --git a/skimage/filter/ctmf.py b/skimage/filter/ctmf.py index 45c387b5..267c5b6c 100644 --- a/skimage/filter/ctmf.py +++ b/skimage/filter/ctmf.py @@ -46,7 +46,7 @@ def median_filter(image, radius=2, mask=None, percent=50): -------- >>> a = np.ones((5, 5)) >>> a[2, 2] = 10 # introduce outlier - >>> b = filter.median_filter(a) + >>> b = median_filter(a) >>> b[2, 2] # the median filter is good at removing outliers 1.0 ''' diff --git a/skimage/measure/find_contours.py b/skimage/measure/find_contours.py index 4a7a6bbf..68e471ac 100755 --- a/skimage/measure/find_contours.py +++ b/skimage/measure/find_contours.py @@ -103,7 +103,7 @@ def find_contours(array, level, array([[ 1., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]]) - >>> measure.find_contours(a, 0.5) + >>> find_contours(a, 0.5) [array([[ 0. , 0.5], [ 0.5, 0. ]])] """