From 20ca89d8b8e6d097959711e8a10ebcaaa34d1825 Mon Sep 17 00:00:00 2001 From: Chintak Sheth Date: Wed, 22 May 2013 00:01:42 +0530 Subject: [PATCH] Added unit test for convex_hull_object function in test_convex_hull.py --- skimage/morphology/tests/test_convex_hull.py | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/skimage/morphology/tests/test_convex_hull.py b/skimage/morphology/tests/test_convex_hull.py index 9ab514d0..1a8b39ef 100644 --- a/skimage/morphology/tests/test_convex_hull.py +++ b/skimage/morphology/tests/test_convex_hull.py @@ -1,7 +1,7 @@ import numpy as np from numpy.testing import assert_array_equal from numpy.testing.decorators import skipif -from skimage.morphology import convex_hull_image +from skimage.morphology import convex_hull_image, convex_hull_object from skimage.morphology._convex_hull import possible_hull try: @@ -65,5 +65,26 @@ def test_possible_hull(): ph = possible_hull(image) assert_array_equal(ph, expected) + +def test_object(): + image = np.array( + [[1, 0, 1, 0, 0, 0, 0, 0, 0], + [1, 0, 1, 0, 1, 0, 0, 0, 1], + [0, 1, 0, 0, 0, 1, 0, 0, 1], + [0, 0, 0, 0, 0, 0, 1, 0, 1], + [0, 0, 0, 0, 0, 0, 0, 1, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=bool) + + expected = np.array( + [[1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 1, 1, 1, 1, 1], + [0, 1, 0, 0, 0, 1, 1, 1, 1], + [0, 0, 0, 0, 0, 0, 1, 1, 1], + [0, 0, 0, 0, 0, 0, 0, 1, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=bool) + + assert_array_equal(convex_hull_object(image), expected) + + if __name__ == "__main__": np.testing.run_module_suite()