added mean method to adaptive thresholding

This commit is contained in:
Johannes Schönberger
2012-04-25 23:44:06 +02:00
parent d81650f992
commit d0d71427af
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -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]):
+2 -2
View File
@@ -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
-------