From 2636abba927b2b3d304daa654f1234ac21f18985 Mon Sep 17 00:00:00 2001 From: emmanuelle Date: Mon, 1 Dec 2014 23:32:21 +0100 Subject: [PATCH 1/3] Small additions to some docstrings in exposure module --- skimage/exposure/exposure.py | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index 7066cc46..6426d755 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -44,6 +44,10 @@ def histogram(image, nbins=256): bin_centers : array The values at the center of the bins. + See also + -------- + cumulative_distribution + Examples -------- >>> from skimage import data, exposure, util @@ -102,10 +106,22 @@ def cumulative_distribution(image, nbins=256): bin_centers : array Centers of bins. + See also + -------- + histogram + References ---------- .. [1] http://en.wikipedia.org/wiki/Cumulative_distribution_function + Examples + -------- + >>> from skimage import data, exposure, util + >>> image = util.img_as_float(data.camera()) + >>> hi = exposure.histogram(image) + >>> cdf = exposure.cumulative_distribution(image) + >>> np.alltrue(cdf[0] == np.cumsum(hi[0])/float(image.size)) + True """ hist, bin_centers = histogram(image, nbins) img_cdf = hist.cumsum() @@ -225,6 +241,10 @@ def rescale_intensity(image, in_range='image', out_range='dtype'): Image array after rescaling its intensity. This image is the same dtype as the input image. + See also + -------- + intensity_range, equalize_hist + Examples -------- By default, the min/max intensities of the input image are stretched to @@ -315,6 +335,10 @@ def adjust_gamma(image, gamma=1, gain=1): out : ndarray Gamma corrected output image. + See also + -------- + adjust_log + Notes ----- For gamma greater than 1, the histogram will shift towards left and @@ -327,6 +351,14 @@ def adjust_gamma(image, gamma=1, gain=1): ---------- .. [1] http://en.wikipedia.org/wiki/Gamma_correction + Examples + -------- + >>> from skimage import data, exposure, util + >>> image = util.img_as_float(data.moon()) + >>> gamma_corrected = exposure.adjust_gamma(image, 2) + >>> # Output is darker for gamma > 1 + >>> image.mean(), gamma_corrected.mean() + (0.43988067028574979, 0.19622774786391453) """ _assert_non_negative(image) dtype = image.dtype.type @@ -362,6 +394,10 @@ def adjust_log(image, gain=1, inv=False): out : ndarray Logarithm corrected output image. + See also + -------- + adjust_gamma + References ---------- .. [1] http://www.ece.ucsb.edu/Faculty/Manjunath/courses/ece178W03/EnhancePart1.pdf @@ -405,6 +441,10 @@ def adjust_sigmoid(image, cutoff=0.5, gain=10, inv=False): out : ndarray Sigmoid corrected output image. + See also + -------- + adjust_gamma + References ---------- .. [1] Gustav J. Braun, "Image Lightness Rescaling Using Sigmoidal Contrast From 5553ea44b39b0bb27151afdf24454dc5ee7abdb7 Mon Sep 17 00:00:00 2001 From: emmanuelle Date: Tue, 2 Dec 2014 22:10:30 +0100 Subject: [PATCH 2/3] Corrected typos + modified docstring that made doctest fail --- skimage/exposure/exposure.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index 6426d755..ff21b686 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -44,14 +44,14 @@ def histogram(image, nbins=256): bin_centers : array The values at the center of the bins. - See also + See Also -------- cumulative_distribution Examples -------- - >>> from skimage import data, exposure, util - >>> image = util.img_as_float(data.camera()) + >>> from skimage import data, exposure + >>> image = skimage.img_as_float(data.camera()) >>> np.histogram(image, bins=2) (array([107432, 154712]), array([ 0. , 0.5, 1. ])) >>> exposure.histogram(image, nbins=2) @@ -106,7 +106,7 @@ def cumulative_distribution(image, nbins=256): bin_centers : array Centers of bins. - See also + See Also -------- histogram @@ -116,8 +116,8 @@ def cumulative_distribution(image, nbins=256): Examples -------- - >>> from skimage import data, exposure, util - >>> image = util.img_as_float(data.camera()) + >>> from skimage import data, exposure + >>> image = skimage.img_as_float(data.camera()) >>> hi = exposure.histogram(image) >>> cdf = exposure.cumulative_distribution(image) >>> np.alltrue(cdf[0] == np.cumsum(hi[0])/float(image.size)) @@ -241,7 +241,7 @@ def rescale_intensity(image, in_range='image', out_range='dtype'): Image array after rescaling its intensity. This image is the same dtype as the input image. - See also + See Also -------- intensity_range, equalize_hist @@ -335,7 +335,7 @@ def adjust_gamma(image, gamma=1, gain=1): out : ndarray Gamma corrected output image. - See also + See Also -------- adjust_log @@ -353,12 +353,12 @@ def adjust_gamma(image, gamma=1, gain=1): Examples -------- - >>> from skimage import data, exposure, util - >>> image = util.img_as_float(data.moon()) + >>> from skimage import data, exposure + >>> image = skimage.img_as_float(data.moon()) >>> gamma_corrected = exposure.adjust_gamma(image, 2) >>> # Output is darker for gamma > 1 - >>> image.mean(), gamma_corrected.mean() - (0.43988067028574979, 0.19622774786391453) + >>> image.mean() > gamma_corrected.mean() + True """ _assert_non_negative(image) dtype = image.dtype.type @@ -394,7 +394,7 @@ def adjust_log(image, gain=1, inv=False): out : ndarray Logarithm corrected output image. - See also + See Also -------- adjust_gamma @@ -441,7 +441,7 @@ def adjust_sigmoid(image, cutoff=0.5, gain=10, inv=False): out : ndarray Sigmoid corrected output image. - See also + See Also -------- adjust_gamma From f9b10c58ad73f75d165781faf69a434b8e8b564b Mon Sep 17 00:00:00 2001 From: emmanuelle Date: Thu, 4 Dec 2014 22:39:42 +0100 Subject: [PATCH 3/3] Corrected another bug that made doctest fail --- skimage/exposure/exposure.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/skimage/exposure/exposure.py b/skimage/exposure/exposure.py index ff21b686..29e3e38c 100644 --- a/skimage/exposure/exposure.py +++ b/skimage/exposure/exposure.py @@ -50,8 +50,8 @@ def histogram(image, nbins=256): Examples -------- - >>> from skimage import data, exposure - >>> image = skimage.img_as_float(data.camera()) + >>> from skimage import data, exposure, img_as_float + >>> image = img_as_float(data.camera()) >>> np.histogram(image, bins=2) (array([107432, 154712]), array([ 0. , 0.5, 1. ])) >>> exposure.histogram(image, nbins=2) @@ -116,8 +116,8 @@ def cumulative_distribution(image, nbins=256): Examples -------- - >>> from skimage import data, exposure - >>> image = skimage.img_as_float(data.camera()) + >>> from skimage import data, exposure, img_as_float + >>> image = img_as_float(data.camera()) >>> hi = exposure.histogram(image) >>> cdf = exposure.cumulative_distribution(image) >>> np.alltrue(cdf[0] == np.cumsum(hi[0])/float(image.size)) @@ -353,10 +353,10 @@ def adjust_gamma(image, gamma=1, gain=1): Examples -------- - >>> from skimage import data, exposure - >>> image = skimage.img_as_float(data.moon()) + >>> from skimage import data, exposure, img_as_float + >>> image = img_as_float(data.moon()) >>> gamma_corrected = exposure.adjust_gamma(image, 2) - >>> # Output is darker for gamma > 1 + >>> # Output is darker for gamma > 1 >>> image.mean() > gamma_corrected.mean() True """