mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 10:12:05 +08:00
check if input for canny is 2d array, test for error raise.
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user