From 6361f3745ebee80c8345a0c7a330f1be3bcc3347 Mon Sep 17 00:00:00 2001 From: Jeremy Metz Date: Sat, 14 May 2016 14:43:46 +0100 Subject: [PATCH] Added test_clear_border_3d --- .../segmentation/tests/test_clear_border.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/skimage/segmentation/tests/test_clear_border.py b/skimage/segmentation/tests/test_clear_border.py index b626ea2b..c300d186 100644 --- a/skimage/segmentation/tests/test_clear_border.py +++ b/skimage/segmentation/tests/test_clear_border.py @@ -28,6 +28,36 @@ def test_clear_border(): assert_array_equal(result, 2 * np.ones_like(image)) +def test_clear_border_3d(): + image = np.array([ + [[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [1, 0, 0, 0]], + [[0, 0, 0, 0], + [0, 1, 1, 0], + [0, 0, 1, 0], + [0, 0, 0, 0]], + [[0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0], + [0, 0, 0, 0]], + ]) + # test default case + result = clear_border(image.copy()) + ref = image.copy() + ref[0, 3, 0] = 0 + assert_array_equal(result, ref) + + # test buffer + result = clear_border(image.copy(), 1) + assert_array_equal(result, np.zeros(result.shape)) + + # test background value + result = clear_border(image.copy(), buffer_size=1, bgval=2) + assert_array_equal(result, 2 * np.ones_like(image)) + + def test_clear_border_non_binary(): image = np.array([[1, 2, 3, 1, 2], [3, 3, 5, 4, 2],