check if input for canny is 2d array, test for error raise.

This commit is contained in:
Andreas Mueller
2011-09-26 17:21:58 +02:00
parent 604296bb51
commit 24d771d333
2 changed files with 7 additions and 0 deletions
+4
View File
@@ -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')
+3
View File
@@ -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)