mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-27 11:27:08 +08:00
Require median filter radius >= 2
The octagon structuring element used by _ctmf.pyx does not scale correctly for smaller radii.
This commit is contained in:
@@ -47,6 +47,9 @@ def median_filter(image, mask=None, radius=2, percent=50):
|
||||
if image.ndim != 2:
|
||||
raise TypeError("The input 'image' must be a two dimensional array.")
|
||||
|
||||
if radius < 2:
|
||||
raise ValueError("The input 'radius' must be >= 2.")
|
||||
|
||||
if mask is None:
|
||||
mask = np.ones(image.shape, dtype=np.bool)
|
||||
mask = np.ascontiguousarray(mask, dtype=np.bool)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import numpy as np
|
||||
from nose.tools import raises
|
||||
|
||||
from skimage.filter import median_filter
|
||||
|
||||
@@ -110,5 +111,11 @@ def test_default_values():
|
||||
np.testing.assert_array_equal(result1, result2)
|
||||
|
||||
|
||||
@raises(ValueError)
|
||||
def test_insufficient_size():
|
||||
img = (np.random.random((20, 20)) * 255).astype(np.uint8)
|
||||
median_filter(img, radius=1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
np.testing.run_module_suite()
|
||||
|
||||
Reference in New Issue
Block a user