From 5ce5f283d02e280577be369f055a24837d42436a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 22:23:04 +0200 Subject: [PATCH 01/10] delete duplicated import --- skimage/io/tests/test_pil.py | 1 - 1 file changed, 1 deletion(-) diff --git a/skimage/io/tests/test_pil.py b/skimage/io/tests/test_pil.py index a9d986d6..3e2f3dde 100644 --- a/skimage/io/tests/test_pil.py +++ b/skimage/io/tests/test_pil.py @@ -55,7 +55,6 @@ def test_imread_palette(): @skipif(not PIL_available) def test_palette_is_gray(): - from PIL import Image gray = Image.open(os.path.join(data_dir, 'palette_gray.png')) assert _palette_is_grayscale(gray) color = Image.open(os.path.join(data_dir, 'palette_color.png')) From 0a4fcdad0a46387cb5c6324dd82034d978c6e613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 22:46:37 +0200 Subject: [PATCH 02/10] fix imports --- skimage/color/tests/test_colorconv.py | 33 +++++++++++++++------------ skimage/feature/tests/test_hog.py | 10 +++++++- skimage/graph/tests/test_heap.py | 3 +-- skimage/graph/tests/test_mcp.py | 5 +++- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/skimage/color/tests/test_colorconv.py b/skimage/color/tests/test_colorconv.py index 7f1d7c73..05ab6915 100644 --- a/skimage/color/tests/test_colorconv.py +++ b/skimage/color/tests/test_colorconv.py @@ -14,23 +14,27 @@ Authors import os.path import numpy as np -from numpy.testing import * +from numpy.testing import (assert_equal, + assert_almost_equal, + assert_array_almost_equal, + assert_raises, + TestCase, + ) from skimage import img_as_float, img_as_ubyte from skimage.io import imread -from skimage.color import ( - rgb2hsv, hsv2rgb, - rgb2xyz, xyz2rgb, - rgb2hed, hed2rgb, - separate_stains, - combine_stains, - rgb2rgbcie, rgbcie2rgb, - convert_colorspace, - rgb2grey, gray2rgb, - xyz2lab, lab2xyz, - lab2rgb, rgb2lab, - is_rgb, is_gray - ) +from skimage.color import (rgb2hsv, hsv2rgb, + rgb2xyz, xyz2rgb, + rgb2hed, hed2rgb, + separate_stains, + combine_stains, + rgb2rgbcie, rgbcie2rgb, + convert_colorspace, + rgb2grey, gray2rgb, + xyz2lab, lab2xyz, + lab2rgb, rgb2lab, + is_rgb, is_gray + ) from skimage import data_dir, data @@ -267,4 +271,5 @@ def test_is_rgb(): if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/feature/tests/test_hog.py b/skimage/feature/tests/test_hog.py index cfef2da0..b37513a5 100644 --- a/skimage/feature/tests/test_hog.py +++ b/skimage/feature/tests/test_hog.py @@ -4,7 +4,10 @@ from skimage import data from skimage import feature from skimage import img_as_float from skimage import draw -from numpy.testing import * +from numpy.testing import (assert_raises, + assert_almost_equal, + ) + def test_histogram_of_oriented_gradients(): img = img_as_float(data.lena()[:256, :].mean(axis=2)) @@ -14,16 +17,19 @@ def test_histogram_of_oriented_gradients(): assert len(fd) == 9 * (256 // 8) * (512 // 8) + def test_hog_image_size_cell_size_mismatch(): image = data.camera()[:150, :200] fd = feature.hog(image, orientations=9, pixels_per_cell=(8, 8), cells_per_block=(1, 1)) assert len(fd) == 9 * (150 // 8) * (200 // 8) + def test_hog_color_image_unsupported_error(): image = np.zeros((20, 20, 3)) assert_raises(ValueError, feature.hog, image) + def test_hog_basic_orientations_and_data_types(): # scenario: # 1) create image (with float values) where upper half is filled by zeros, bottom half by 100 @@ -90,6 +96,7 @@ def test_hog_basic_orientations_and_data_types(): assert_almost_equal(actual, desired, decimal=2) + def test_hog_orientations_circle(): # scenario: # 1) create image with blurred circle in the middle @@ -129,6 +136,7 @@ def test_hog_orientations_circle(): desired = np.mean(hog_matrix) assert_almost_equal(actual, desired, decimal=1) + if __name__ == '__main__': from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/graph/tests/test_heap.py b/skimage/graph/tests/test_heap.py index 8322fd4e..cf7e3d0b 100644 --- a/skimage/graph/tests/test_heap.py +++ b/skimage/graph/tests/test_heap.py @@ -1,5 +1,3 @@ -from numpy.testing import * - import time import random import skimage.graph.heap as heap @@ -49,4 +47,5 @@ def _test_heap(n, fast_update): return t1 - t0 if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/graph/tests/test_mcp.py b/skimage/graph/tests/test_mcp.py index e3fd45a0..8712c0e9 100644 --- a/skimage/graph/tests/test_mcp.py +++ b/skimage/graph/tests/test_mcp.py @@ -1,5 +1,8 @@ import numpy as np -from numpy.testing import * +from numpy.testing import (assert_array_equal, + assert_almost_equal, + ) + import skimage.graph.mcp as mcp From b9572e8c68ae3847455a5a3ada682f0ea12afd75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 22:47:08 +0200 Subject: [PATCH 03/10] remove commented lines --- skimage/graph/tests/test_mcp.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/skimage/graph/tests/test_mcp.py b/skimage/graph/tests/test_mcp.py index 8712c0e9..a1021380 100644 --- a/skimage/graph/tests/test_mcp.py +++ b/skimage/graph/tests/test_mcp.py @@ -3,22 +3,12 @@ from numpy.testing import (assert_array_equal, assert_almost_equal, ) - import skimage.graph.mcp as mcp a = np.ones((8, 8), dtype=np.float32) a[1:-1, 1] = 0 a[1, 1:-1] = 0 -## array([[ 1., 1., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 0., 0., 0., 0., 0., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 1., 1., 1., 1., 1., 1., 1.]], dtype=float32) - def test_basic(): m = mcp.MCP(a, fully_connected=True) From 6f6d207eb2e25c4e504bb53406dfe006bf74a3d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 22:53:13 +0200 Subject: [PATCH 04/10] fix import --- skimage/io/tests/test_simpleitk.py | 2 +- skimage/measure/tests/test_find_contours.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/skimage/io/tests/test_simpleitk.py b/skimage/io/tests/test_simpleitk.py index 4bb2cc23..2d4bd84b 100644 --- a/skimage/io/tests/test_simpleitk.py +++ b/skimage/io/tests/test_simpleitk.py @@ -1,6 +1,5 @@ import os.path import numpy as np -from numpy.testing import * from numpy.testing.decorators import skipif from tempfile import NamedTemporaryFile @@ -90,4 +89,5 @@ class TestSave: yield self.roundtrip, dtype, x if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/measure/tests/test_find_contours.py b/skimage/measure/tests/test_find_contours.py index 11b9b443..25de1e53 100644 --- a/skimage/measure/tests/test_find_contours.py +++ b/skimage/measure/tests/test_find_contours.py @@ -1,5 +1,7 @@ import numpy as np -from numpy.testing import * +from numpy.testing import (assert_raises, + assert_array_equal, + ) from skimage.measure import find_contours From 5c3eef0d86ff3906b846ec2fb3f00bd44185edf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 22:53:32 +0200 Subject: [PATCH 05/10] delete comment --- skimage/measure/tests/test_find_contours.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/skimage/measure/tests/test_find_contours.py b/skimage/measure/tests/test_find_contours.py index 25de1e53..da2497eb 100644 --- a/skimage/measure/tests/test_find_contours.py +++ b/skimage/measure/tests/test_find_contours.py @@ -9,15 +9,6 @@ a = np.ones((8, 8), dtype=np.float32) a[1:-1, 1] = 0 a[1, 1:-1] = 0 -## array([[ 1., 1., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 0., 0., 0., 0., 0., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 0., 1., 1., 1., 1., 1., 1.], -## [ 1., 1., 1., 1., 1., 1., 1., 1.]], dtype=float32) - x, y = np.mgrid[-1:1:5j, -1:1:5j] r = np.sqrt(x**2 + y**2) From 84bff0860116fe37b139279bff602e4625c87969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 23:08:39 +0200 Subject: [PATCH 06/10] fix import testing --- skimage/io/tests/test_collection.py | 6 +++++- skimage/io/tests/test_colormixer.py | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/skimage/io/tests/test_collection.py b/skimage/io/tests/test_collection.py index 2bbfefa7..f650daeb 100644 --- a/skimage/io/tests/test_collection.py +++ b/skimage/io/tests/test_collection.py @@ -2,7 +2,10 @@ import sys import os.path import numpy as np -from numpy.testing import * +from numpy.testing import (assert_raises, + assert_equal, + assert_array_almost_equal, + ) from numpy.testing.decorators import skipif from skimage import data_dir @@ -148,4 +151,5 @@ class TestMultiImage(): if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/io/tests/test_colormixer.py b/skimage/io/tests/test_colormixer.py index b9f362a2..392a7b5b 100644 --- a/skimage/io/tests/test_colormixer.py +++ b/skimage/io/tests/test_colormixer.py @@ -1,4 +1,8 @@ -from numpy.testing import * +from numpy.testing import (assert_array_equal, + assert_almost_equal, + assert_equal, + assert_array_almost_equal, + ) import numpy as np import skimage.io._plugins._colormixer as cm @@ -136,4 +140,5 @@ class TestColorMixer(object): if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() From a9f962695e3e73a59ee3b1f705c40bb0812b3913 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 23:12:16 +0200 Subject: [PATCH 07/10] add spaces for travis (pep8) --- skimage/morphology/tests/test_watershed.py | 84 +++++++++++----------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/skimage/morphology/tests/test_watershed.py b/skimage/morphology/tests/test_watershed.py index 46298ae5..660e9a9a 100644 --- a/skimage/morphology/tests/test_watershed.py +++ b/skimage/morphology/tests/test_watershed.py @@ -296,27 +296,27 @@ class TestWatershed(unittest.TestCase): def test_watershed07(self): "A regression test of a competitive case that failed" - data = np.array([[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255], - [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255], - [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255], - [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255], - [255,255,204,153,111, 72, 39, 1, 1, 39, 72,111,153,204,255,255], - [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255], - [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255], - [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255], - [255,255,255,255,255,204,153,103,103,153,204,255,255,255,255,255], - [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255], - [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255], - [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255], - [255,255,204,153,111, 72, 39, 1, 1, 39, 72,111,153,204,255,255], - [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255], - [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255], - [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255], - [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]]) + data = np.array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 204, 204, 204, 204, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 204, 204, 183, 153, 153, 153, 153, 183, 204, 204, 255, 255, 255], + [255, 255, 204, 183, 153, 141, 111, 103, 103, 111, 141, 153, 183, 204, 255, 255], + [255, 255, 204, 153, 111, 94, 72, 52, 52, 72, 94, 111, 153, 204, 255, 255], + [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], + [255, 255, 204, 183, 141, 111, 72, 39, 39, 72, 111, 141, 183, 204, 255, 255], + [255, 255, 255, 204, 183, 141, 111, 72, 72, 111, 141, 183, 204, 255, 255, 255], + [255, 255, 255, 255, 204, 183, 141, 94, 94, 141, 183, 204, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 153, 103, 103, 153, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 204, 183, 141, 94, 94, 141, 183, 204, 255, 255, 255, 255], + [255, 255, 255, 204, 183, 141, 111, 72, 72, 111, 141, 183, 204, 255, 255, 255], + [255, 255, 204, 183, 141, 111, 72, 39, 39, 72, 111, 141, 183, 204, 255, 255], + [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], + [255, 255, 204, 153, 111, 94, 72, 52, 52, 72, 94, 111, 153, 204, 255, 255], + [255, 255, 204, 183, 153, 141, 111, 103, 103, 111, 141, 153, 183, 204, 255, 255], + [255, 255, 255, 204, 204, 183, 153, 153, 153, 153, 183, 204, 204, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 204, 204, 204, 204, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]) mask = (data != 255) markers = np.zeros(data.shape, int) markers[6, 7] = 1 @@ -332,27 +332,27 @@ class TestWatershed(unittest.TestCase): def test_watershed08(self): "The border pixels + an edge are all the same value" - data = np.array([[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255], - [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255], - [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255], - [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255], - [255,255,204,153,111, 72, 39, 1, 1, 39, 72,111,153,204,255,255], - [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255], - [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255], - [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255], - [255,255,255,255,255,204,153,141,141,153,204,255,255,255,255,255], - [255,255,255,255,204,183,141, 94, 94,141,183,204,255,255,255,255], - [255,255,255,204,183,141,111, 72, 72,111,141,183,204,255,255,255], - [255,255,204,183,141,111, 72, 39, 39, 72,111,141,183,204,255,255], - [255,255,204,153,111, 72, 39, 1, 1, 39, 72,111,153,204,255,255], - [255,255,204,153,111, 94, 72, 52, 52, 72, 94,111,153,204,255,255], - [255,255,204,183,153,141,111,103,103,111,141,153,183,204,255,255], - [255,255,255,204,204,183,153,153,153,153,183,204,204,255,255,255], - [255,255,255,255,255,204,204,204,204,204,204,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], - [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255]]) + data = np.array([[255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 204, 204, 204, 204, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 204, 204, 183, 153, 153, 153, 153, 183, 204, 204, 255, 255, 255], + [255, 255, 204, 183, 153, 141, 111, 103, 103, 111, 141, 153, 183, 204, 255, 255], + [255, 255, 204, 153, 111, 94, 72, 52, 52, 72, 94, 111, 153, 204, 255, 255], + [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], + [255, 255, 204, 183, 141, 111, 72, 39, 39, 72, 111, 141, 183, 204, 255, 255], + [255, 255, 255, 204, 183, 141, 111, 72, 72, 111, 141, 183, 204, 255, 255, 255], + [255, 255, 255, 255, 204, 183, 141, 94, 94, 141, 183, 204, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 153, 141, 141, 153, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 204, 183, 141, 94, 94, 141, 183, 204, 255, 255, 255, 255], + [255, 255, 255, 204, 183, 141, 111, 72, 72, 111, 141, 183, 204, 255, 255, 255], + [255, 255, 204, 183, 141, 111, 72, 39, 39, 72, 111, 141, 183, 204, 255, 255], + [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], + [255, 255, 204, 153, 111, 94, 72, 52, 52, 72, 94, 111, 153, 204, 255, 255], + [255, 255, 204, 183, 153, 141, 111, 103, 103, 111, 141, 153, 183, 204, 255, 255], + [255, 255, 255, 204, 204, 183, 153, 153, 153, 153, 183, 204, 204, 255, 255, 255], + [255, 255, 255, 255, 255, 204, 204, 204, 204, 204, 204, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255], + [255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]]) mask = (data != 255) markers = np.zeros(data.shape, int) markers[6, 7] = 1 From 77d7b25b52c691fa896cb61eb7f05a1893934c2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 23:26:10 +0200 Subject: [PATCH 08/10] fix import testing --- skimage/transform/tests/test_finite_radon_transform.py | 8 ++++++-- skimage/transform/tests/test_integral.py | 3 ++- skimage/transform/tests/test_radon_transform.py | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/skimage/transform/tests/test_finite_radon_transform.py b/skimage/transform/tests/test_finite_radon_transform.py index b5fcf43a..c4c4de7e 100644 --- a/skimage/transform/tests/test_finite_radon_transform.py +++ b/skimage/transform/tests/test_finite_radon_transform.py @@ -1,7 +1,6 @@ import numpy as np -from numpy.testing import * -from skimage.transform import * +from skimage.transform import frt2, ifrt2 def test_frt(): @@ -17,3 +16,8 @@ def test_frt(): f = frt2(L) fi = ifrt2(f) assert len(np.nonzero(L - fi)[0]) == 0 + +if __name__ == '__main__': + from numpy.testing import run_module_suite + run_module_suite() + diff --git a/skimage/transform/tests/test_integral.py b/skimage/transform/tests/test_integral.py index ed973cec..4a641e71 100644 --- a/skimage/transform/tests/test_integral.py +++ b/skimage/transform/tests/test_integral.py @@ -1,5 +1,5 @@ import numpy as np -from numpy.testing import * +from numpy.testing import assert_equal from skimage.transform import integral_image, integrate @@ -43,4 +43,5 @@ def test_vectorized_integrate(): if __name__ == '__main__': + from numpy.testing import run_module_suite run_module_suite() diff --git a/skimage/transform/tests/test_radon_transform.py b/skimage/transform/tests/test_radon_transform.py index c0fc883d..79cf80c5 100644 --- a/skimage/transform/tests/test_radon_transform.py +++ b/skimage/transform/tests/test_radon_transform.py @@ -181,4 +181,5 @@ def test_radon_iradon_circle(): if __name__ == "__main__": + from numpy.testing import run_module_suite run_module_suite() From a165cf3dcab632844238e6551553b8a02ee4ebc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Thu, 20 Jun 2013 23:28:49 +0200 Subject: [PATCH 09/10] pep8 --- skimage/morphology/_skeletonize.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/skimage/morphology/_skeletonize.py b/skimage/morphology/_skeletonize.py index e9818ea9..bd9f225c 100644 --- a/skimage/morphology/_skeletonize.py +++ b/skimage/morphology/_skeletonize.py @@ -84,14 +84,18 @@ def skeletonize(image): # look up table - there is one entry for each of the 2^8=256 possible # 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,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,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] + 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, 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, 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] # convert to unsigned int (this should work for boolean values) skeleton = image.astype(np.uint8) From 8aad4d6e948e3b88a8d523acddd90edf22ce1a57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Fri, 21 Jun 2013 19:13:18 +0200 Subject: [PATCH 10/10] fix missing space --- skimage/morphology/tests/test_watershed.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/morphology/tests/test_watershed.py b/skimage/morphology/tests/test_watershed.py index 660e9a9a..82531713 100644 --- a/skimage/morphology/tests/test_watershed.py +++ b/skimage/morphology/tests/test_watershed.py @@ -302,7 +302,7 @@ class TestWatershed(unittest.TestCase): [255, 255, 255, 204, 204, 183, 153, 153, 153, 153, 183, 204, 204, 255, 255, 255], [255, 255, 204, 183, 153, 141, 111, 103, 103, 111, 141, 153, 183, 204, 255, 255], [255, 255, 204, 153, 111, 94, 72, 52, 52, 72, 94, 111, 153, 204, 255, 255], - [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], + [255, 255, 204, 153, 111, 72, 39, 1, 1, 39, 72, 111, 153, 204, 255, 255], [255, 255, 204, 183, 141, 111, 72, 39, 39, 72, 111, 141, 183, 204, 255, 255], [255, 255, 255, 204, 183, 141, 111, 72, 72, 111, 141, 183, 204, 255, 255, 255], [255, 255, 255, 255, 204, 183, 141, 94, 94, 141, 183, 204, 255, 255, 255, 255],