diff --git a/skimage/morphology/convex_hull.py b/skimage/morphology/convex_hull.py index b6e1b43a..d092b122 100644 --- a/skimage/morphology/convex_hull.py +++ b/skimage/morphology/convex_hull.py @@ -66,7 +66,7 @@ def convex_hull_image(image): return mask -def convex_hull_object(image, neighbors=8): +def convex_hull_object(image, neighbors): """Compute the convex hull image of individual objects in a binary image. The convex hull is the set of pixels included in the smallest convex diff --git a/skimage/morphology/tests/test_convex_hull.py b/skimage/morphology/tests/test_convex_hull.py index 8b499709..67d77a31 100644 --- a/skimage/morphology/tests/test_convex_hull.py +++ b/skimage/morphology/tests/test_convex_hull.py @@ -69,23 +69,41 @@ def test_possible_hull(): @skipif(not scipy_spatial) 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], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 1, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 1, 0], + [1, 0, 0, 0, 0, 0, 1, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 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], + expected4 = np.array( + [[0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 1, 0, 1], + [1, 1, 1, 0, 0, 0, 0, 1, 0], + [1, 1, 0, 0, 0, 0, 1, 0, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=bool) - assert_array_equal(convex_hull_object(image), expected) + assert_array_equal(convex_hull_object(image, 4), expected4) + expected8 = np.array( + [[0, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 0, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 0, 0, 0, 0, 0, 0], + [1, 1, 1, 1, 0, 0, 1, 1, 1], + [1, 1, 1, 0, 0, 0, 1, 1, 1], + [1, 1, 0, 0, 0, 0, 1, 1, 1], + [1, 0, 0, 0, 0, 0, 0, 0, 0], + [0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=bool) + + assert_array_equal(convex_hull_object(image, 8), expected8) if __name__ == "__main__": np.testing.run_module_suite()