diff --git a/scikits/image/filter/canny.py b/scikits/image/filter/canny.py index 341d5b77..dd3b5608 100644 --- a/scikits/image/filter/canny.py +++ b/scikits/image/filter/canny.py @@ -111,6 +111,10 @@ def canny(image, sigma, low_threshold, high_threshold, mask=None): # mask by one and then mask the output. We also mask out the border points # because who knows what lies beyond the edge of the image? # + + if image.ndim!=2: + raise TypeError("The input 'image' must be a two dimensional array.") + if mask is None: mask = np.ones(image.shape, dtype=bool) fsmooth = lambda x: gaussian_filter(x, sigma, mode='constant') diff --git a/scikits/image/filter/tests/test_canny.py b/scikits/image/filter/tests/test_canny.py index f7002773..ddadc790 100644 --- a/scikits/image/filter/tests/test_canny.py +++ b/scikits/image/filter/tests/test_canny.py @@ -56,3 +56,6 @@ class TestCanny(unittest.TestCase): point_count = np.sum(result) self.assertTrue(point_count > 1200) self.assertTrue(point_count < 1600) + + def test_image_shape(self): + self.assertRaises(TypeError,F.canny,np.zeros((20, 20, 20)), 4, 0, 0)