diff --git a/scikits/image/data/bw_text.png b/scikits/image/data/bw_text.png new file mode 100644 index 00000000..fd1a4c7c Binary files /dev/null and b/scikits/image/data/bw_text.png differ diff --git a/scikits/image/data/bw_text_skeleton.npy b/scikits/image/data/bw_text_skeleton.npy new file mode 100644 index 00000000..9492cb64 Binary files /dev/null and b/scikits/image/data/bw_text_skeleton.npy differ diff --git a/scikits/image/morphology/tests/test_skeletonize.py b/scikits/image/morphology/tests/test_skeletonize.py index 5a6bacb9..841fcfbe 100644 --- a/scikits/image/morphology/tests/test_skeletonize.py +++ b/scikits/image/morphology/tests/test_skeletonize.py @@ -4,6 +4,9 @@ from scikits.image.morphology import skeletonize import numpy.testing from scikits.image.draw import draw from scipy.ndimage import correlate +from scikits.image.io import imread +from scikits.image import data_dir +import os.path class TestSkeletonize(unittest.TestCase): def test_skeletonize_no_foreground(self): @@ -48,6 +51,17 @@ class TestSkeletonize(unittest.TestCase): result = skeletonize.skeletonize(im) numpy.testing.assert_array_equal(result, im) + def test_skeletonize_output(self): + im = imread(os.path.join(data_dir, "bw_text.png"), as_grey=True) + + # make black the foreground + im = (im==0) + result = skeletonize.skeletonize(im) + + expected = np.load(os.path.join(data_dir, "bw_text_skeleton.npy")) + numpy.testing.assert_array_equal(result, expected) + + def test_skeletonize_num_neighbours(self): # an empty image image = np.zeros((300, 300))