diff --git a/skimage/filter/_thresholding.pyx b/skimage/filter/_thresholding.pyx index 303c1a5f..88badf31 100644 --- a/skimage/filter/_thresholding.pyx +++ b/skimage/filter/_thresholding.pyx @@ -19,6 +19,9 @@ def _adaptive_threshold( sigma = (block_size - 1) / 6.0 mean_image = scipy.ndimage.gaussian_filter(image, sigma) elif method == 'mean': + mask = 1. / block_size**2 * np.ones((block_size, block_size)) + mean_image = scipy.ndimage.convolve(image, mask) + elif method == 'median': mean_image = scipy.ndimage.median_filter(image, block_size) for r in range(image.shape[0]): diff --git a/skimage/filter/thresholding.py b/skimage/filter/thresholding.py index d0d95a4a..09e6eaea 100644 --- a/skimage/filter/thresholding.py +++ b/skimage/filter/thresholding.py @@ -25,8 +25,8 @@ def adaptive_threshold(image, block_size, offset, method='gaussian'): constant subtracted from weighted mean of neighborhood to calculate the local threshold value method : string, optional - thresholding type which must be one of `gaussian` or `mean`. - By default the `gaussian` method is used. + thresholding type which must be one of 'gaussian', 'mean' or 'median'. + By default the 'gaussian' method is used. Returns -------