From c8f0611a5442c37214c01f4a1a1fcd5824b82466 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Fri, 10 Jun 2016 11:03:16 +0200 Subject: [PATCH] ADD mean and triangle thres --- skimage/filters/thresholding.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/skimage/filters/thresholding.py b/skimage/filters/thresholding.py index 61ff319d..3b226779 100644 --- a/skimage/filters/thresholding.py +++ b/skimage/filters/thresholding.py @@ -9,14 +9,15 @@ from .._shared.utils import assert_nD, warn from ..morphology import disk from ..filters.rank import otsu - __all__ = ['try_all_threshold', 'threshold_adaptive', 'threshold_otsu', 'threshold_yen', 'threshold_isodata', 'threshold_li', - 'threshold_minimum', ] + 'threshold_minimum', + 'threshold_mean', + 'threshold_triangle'] def _try_all(image, methods=None, figsize=None, num_cols=2, verbose=True): @@ -92,8 +93,10 @@ def try_all_threshold(image, radius=None, figsize=(8, 5), verbose=True): * isodata * li + * mean * minimum * otsu + * triangle * yen * adaptive threshold (local) * rank otsu (local) @@ -132,8 +135,10 @@ def try_all_threshold(image, radius=None, figsize=(8, 5), verbose=True): # Global algorithms. methods = OrderedDict({'Isodata': thresh(threshold_isodata), 'Li': thresh(threshold_li), + 'Mean': thresh(threshold_mean), 'Minimum': thresh(threshold_minimum), 'Otsu': thresh(threshold_otsu), + 'Triangle': thresh(threshold_triangle), 'Yen': thresh(threshold_yen)}) # Local algorithms. @@ -150,15 +155,6 @@ def try_all_threshold(image, radius=None, figsize=(8, 5), verbose=True): return _try_all(image, figsize=figsize, methods=methods, verbose=verbose) -__all__ = ['threshold_adaptive', - 'threshold_otsu', - 'threshold_yen', - 'threshold_isodata', - 'threshold_li', - 'threshold_minimum', - 'threshold_mean', - 'threshold_triangle'] - def threshold_adaptive(image, block_size, method='gaussian', offset=0, mode='reflect', param=None): @@ -288,8 +284,8 @@ def threshold_otsu(image, nbins=256): # Check if the image is multi-colored or not if image.min() == image.max(): - raise ValueError("threshold_otsu is expected to work with images " \ - "having more than one color. The input image seems " \ + raise ValueError("threshold_otsu is expected to work with images " + "having more than one color. The input image seems " "to have just one color {0}.".format(image.min())) hist, bin_centers = histogram(image.ravel(), nbins)