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:
Tony S Yu
2011-10-26 16:22:20 -04:00
parent 573e208361
commit a63e3f4546
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -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)
+7
View File
@@ -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()