diff --git a/skimage/data/bw_text_skeleton.npy b/skimage/data/bw_text_skeleton.npy index 9492cb64..2933c484 100644 Binary files a/skimage/data/bw_text_skeleton.npy and b/skimage/data/bw_text_skeleton.npy differ diff --git a/skimage/morphology/_skeletonize.py b/skimage/morphology/_skeletonize.py index 58842c6d..04a65da6 100644 --- a/skimage/morphology/_skeletonize.py +++ b/skimage/morphology/_skeletonize.py @@ -85,10 +85,10 @@ def skeletonize(image): # combinations of 8 binary neighbours. 1's, 2's and 3's are candidates # for removal at each iteration of the algorithm. lut = [ 0,0,0,1,0,0,1,3,0,0,3,1,1,0,1,3,0,0,0,0,0,0,0,0,2,0,2,0,3,0,3,3, - 0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,3,0,2,2, + 0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,3,0,2,2, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2,0,0,0,0,0,0,0,2,0,0,0,2,0,0,0,3,0,0,0,0,0,0,0,3,0,0,0,3,0,2,0, - 0,1,3,1,0,0,1,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, + 0,0,3,1,0,0,1,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 3,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2,3,1,3,0,0,1,3,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2,3,0,1,0,0,0,1,0,0,0,0,0,0,0,0,3,3,0,1,0,0,0,0,2,2,0,0,2,0,0,0] diff --git a/skimage/morphology/tests/test_skeletonize.py b/skimage/morphology/tests/test_skeletonize.py index 2f9d046e..c9cdbc24 100644 --- a/skimage/morphology/tests/test_skeletonize.py +++ b/skimage/morphology/tests/test_skeletonize.py @@ -92,6 +92,23 @@ class TestSkeletonize(): blocks = correlate(result, mask, mode='constant') assert not numpy.any(blocks == 4) + def test_lut_fix(self): + im = np.zeros((6, 6), np.uint8) + im[1, 2] = 1 + im[2, 2] = 1 + im[2, 3] = 1 + im[3, 3] = 1 + im[3, 4] = 1 + im[4, 4] = 1 + im[4, 5] = 1 + result = skeletonize(im) + expected = np.array([[0, 0, 0, 0, 0, 0], + [0, 0, 1, 0, 0, 0], + [0, 0, 0, 1, 0, 0], + [0, 0, 0, 0, 1, 0], + [0, 0, 0, 0, 0, 1], + [0, 0, 0, 0, 0, 0]], dtype=np.uint8) + assert np.all(result == expected) class TestMedialAxis(): def test_00_00_zeros(self):