From 9fef985df8ded4f43753f2876a66c267957699a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Sun, 19 Jun 2016 09:37:26 +0200 Subject: [PATCH] Various fixes --- .../segmentation/plot_thresholding.py | 8 +++--- .../xx_applications/plot_thresholding.py | 26 +++++++++---------- skimage/filters/__init__.py | 3 ++- skimage/filters/thresholding.py | 4 +-- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/doc/examples/segmentation/plot_thresholding.py b/doc/examples/segmentation/plot_thresholding.py index 1324db72..9a3ccb0d 100644 --- a/doc/examples/segmentation/plot_thresholding.py +++ b/doc/examples/segmentation/plot_thresholding.py @@ -21,6 +21,7 @@ Thresholding is used to create a binary image from a grayscale image [1]_. # the intra-class variance. # # .. [2] http://en.wikipedia.org/wiki/Otsu's_method +# import matplotlib.pyplot as plt from skimage import data @@ -59,13 +60,14 @@ plt.show() # thresholding algorithms provided by the library. At a glance, you can select # the best algorithm for you data without a deep understanding of their # mechanisms. +# -from skimage.filters import thresholding +from skimage.filters import try_all_threshold img = data.page() # Here, we specify a radius for local thresholding algorithms. # If it is not specified, only global algorithms are called. -fig, ax = thresholding.try_all_threshold(img, radius=20, - figsize=(10, 8), verbose=False) +fig, ax = try_all_threshold(img, radius=20, + figsize=(10, 8), verbose=False) plt.show() diff --git a/doc/examples/xx_applications/plot_thresholding.py b/doc/examples/xx_applications/plot_thresholding.py index e6a93242..92e4556b 100644 --- a/doc/examples/xx_applications/plot_thresholding.py +++ b/doc/examples/xx_applications/plot_thresholding.py @@ -32,14 +32,14 @@ import matplotlib import matplotlib.pyplot as plt from skimage import data -from skimage.filters import thresholding +from skimage.filters import try_all_threshold img = data.page() # Here, we specify a radius for local thresholding algorithms. # If it is not specified, only global algorithms are called. -fig, ax = thresholding.try_all_threshold(img, radius=20, - figsize=(10, 8), verbose=False) +fig, ax = try_all_threshold(img, radius=20, + figsize=(10, 8), verbose=False) plt.show() ###################################################################### @@ -49,8 +49,9 @@ plt.show() # Now, we illustrate how to apply one of these thresholding algorithms. # This example uses the mean value of pixel intensities. It is a simple # and naive threshold value, which is sometimes used as a guess value. +# -from skimage.filters.thresholding import threshold_mean +from skimage.filters import threshold_mean image = data.camera() @@ -77,12 +78,13 @@ plt.show() # # For pictures with a bimodal histogram, more specific algorithms can be used. # For instance, the minimum algorithm takes a histogram of the image and smooths it -# repeatedly until there are only two peaks in the histogram. Then it -# finds the minimum value between the two peaks. After smoothing the +# repeatedly until there are only two peaks in the histogram. Then it +# finds the minimum value between the two peaks. After smoothing the # histogram, there can be multiple pixel values with the minimum histogram # count, so you can pick the 'min', 'mid', or 'max' of these values. +# -from skimage.filters.thresholding import threshold_minimum +from skimage.filters import threshold_minimum image = data.camera() @@ -131,11 +133,8 @@ plt.show() # the intra-class variance. # # .. [2] http://en.wikipedia.org/wiki/Otsu's_method +# -import matplotlib -import matplotlib.pyplot as plt - -from skimage import data from skimage.filters import threshold_otsu @@ -175,8 +174,9 @@ plt.show() # # Here, we binarize an image using the `threshold_adaptive` function, which # calculates thresholds in regions with a characteristic size `block_size` surrounding -# each pixel (i.e. local neighborhoods). Each threshold value is the weighted mean -# of the local neighborhood minus an offset value. +# each pixel (i.e. local neighborhoods). Each threshold value is the weighted mean +# of the local neighborhood minus an offset value. +# from skimage.filters import threshold_otsu, threshold_adaptive diff --git a/skimage/filters/__init__.py b/skimage/filters/__init__.py index 9ae67a5c..61fc850c 100644 --- a/skimage/filters/__init__.py +++ b/skimage/filters/__init__.py @@ -8,7 +8,8 @@ from .edges import (sobel, sobel_h, sobel_v, from ._rank_order import rank_order from ._gabor import gabor_kernel, gabor from .thresholding import (threshold_adaptive, threshold_otsu, threshold_yen, - threshold_isodata, threshold_li, threshold_minimum) + threshold_isodata, threshold_li, threshold_minimum, + threshold_mean, threshold_triangle, try_all_threshold) from . import rank from .rank import median diff --git a/skimage/filters/thresholding.py b/skimage/filters/thresholding.py index 97b3e5e9..06493880 100644 --- a/skimage/filters/thresholding.py +++ b/skimage/filters/thresholding.py @@ -102,8 +102,8 @@ def try_all_threshold(image, radius=None, figsize=(8, 5), verbose=True): * adaptive threshold (local) * rank otsu (local) - Example - ------- + Examples + -------- >>> from skimage.data import text >>> fig, ax = try_all_threshold(text(), radius=20, ... figsize=(10, 6), verbose=False)