From ebc020fe01d38c50ad4485b76adb882c25e78c93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 16 Jan 2013 20:01:41 +0100 Subject: [PATCH 1/9] Wrap line and group imports --- skimage/draw/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/skimage/draw/__init__.py b/skimage/draw/__init__.py index 67692f1b..4aa6bf35 100644 --- a/skimage/draw/__init__.py +++ b/skimage/draw/__init__.py @@ -1,2 +1,5 @@ -from ._draw import line, polygon, ellipse, circle, circle_perimeter, ellipse_perimeter, set_color +from ._draw import line, polygon, ellipse, ellipse_perimeter, \ + circle, circle_perimeter, set_color + + bresenham = line From 8578158f1d31c7b427f01a19503c9177e4593102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 16 Jan 2013 20:06:53 +0100 Subject: [PATCH 2/9] Make some stylistic code layout changes --- skimage/draw/_draw.pyx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/skimage/draw/_draw.pyx b/skimage/draw/_draw.pyx index 033de8f0..e0c9231e 100644 --- a/skimage/draw/_draw.pyx +++ b/skimage/draw/_draw.pyx @@ -28,6 +28,7 @@ def line(int y, int x, int y2, int x2): ``img[rr, cc] = 1``. """ + cdef np.ndarray[np.int32_t, ndim=1, mode="c"] rr, cc cdef int steep = 0 @@ -92,7 +93,9 @@ def polygon(y, x, shape=None): Pixel coordinates of polygon. May be used to directly index into an array, e.g. ``img[rr, cc] = 1``. + """ + cdef int nr_verts = x.shape[0] cdef int minr = max(0, y.min()) cdef int maxr = math.ceil(y.max()) @@ -142,7 +145,9 @@ def ellipse(double cy, double cx, double yradius, double xradius, shape=None): Pixel coordinates of ellipse. May be used to directly index into an array, e.g. ``img[rr, cc] = 1``. + """ + cdef int minr = max(0, cy - yradius) cdef int maxr = math.ceil(cy + yradius) cdef int minc = max(0, cx - xradius) @@ -184,7 +189,9 @@ def circle(double cy, double cx, double radius, shape=None): Pixel coordinates of circle. May be used to directly index into an array, e.g. ``img[rr, cc] = 1``. + """ + return ellipse(cy, cx, radius, radius, shape) @@ -287,16 +294,16 @@ def ellipse_perimeter(int cy, int cx, int yradius, int xradius): ---------- .. [1] J. Kennedy "A fast Bresenham type algorithm for drawing ellipses". + """ - # If both radii == 0, return the center - # to avoid infinite loop in 2nd set + + # If both radii == 0, return the center to avoid infinite loop in 2nd set if xradius == 0 and yradius == 0: return np.array(cy), np.array(cx) - # a and b are xradius an yradius - # compute 2a^2 and 2b^2 - cdef int twoasquared = 2 * xradius * xradius - cdef int twobsquared = 2 * yradius * yradius + # a and b are xradius an yradius compute 2a^2 and 2b^2 + cdef int twoasquared = 2 * xradius**2 + cdef int twobsquared = 2 * yradius**2 # Pixels cdef list px = list() @@ -353,8 +360,9 @@ def ellipse_perimeter(int cy, int cx, int yradius, int xradius): def set_color(img, coords, color): - """Set pixel color in the image at the given coordinates. Coordinates that - exceed the shape of the image will be ignored. + """Set pixel color in the image at the given coordinates. + + Coordinates that exceed the shape of the image will be ignored. Parameters ---------- @@ -369,7 +377,9 @@ def set_color(img, coords, color): ------- img : (M, N, D) ndarray The updated image. + """ + rr, cc = coords rr_inside = np.logical_and(rr >= 0, rr < img.shape[0]) cc_inside = np.logical_and(cc >= 0, cc < img.shape[1]) From 697c173227110a791c6237828bb773af6661af10 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Wed, 16 Jan 2013 19:37:47 -0600 Subject: [PATCH 3/9] BUG: Update bento build to match setup files. --- bento.info | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bento.info b/bento.info index 8e001582..57d9f714 100644 --- a/bento.info +++ b/bento.info @@ -64,9 +64,9 @@ Library: Extension: skimage.filter._ctmf Sources: skimage/filter/_ctmf.pyx - Extension: skimage.filter._denoise + Extension: skimage.filter._denoise_cy Sources: - skimage/filter/_denoise.pyx + skimage/filter/_denoise_cy.pyx Extension: skimage.morphology.ccomp Sources: skimage/morphology/ccomp.pyx @@ -91,6 +91,9 @@ Library: Extension: skimage.morphology._greyreconstruct Sources: skimage/morphology/_greyreconstruct.pyx + Extension: skimage.feature.corner_cy + Sources: + skimage/feature/corner_cy.pyx Extension: skimage.feature._texture Sources: skimage/feature/_texture.pyx From 6d2aad45ab52e1a062f8f9cbc3efa62783c53d7d Mon Sep 17 00:00:00 2001 From: "Josh Warner (Mac)" Date: Wed, 16 Jan 2013 23:35:50 -0600 Subject: [PATCH 4/9] fix: set random seed in `test_noisy_square_image` --- skimage/feature/tests/test_corner.py | 1 + 1 file changed, 1 insertion(+) diff --git a/skimage/feature/tests/test_corner.py b/skimage/feature/tests/test_corner.py index 46e5466f..a7ee01ff 100644 --- a/skimage/feature/tests/test_corner.py +++ b/skimage/feature/tests/test_corner.py @@ -31,6 +31,7 @@ def test_square_image(): def test_noisy_square_image(): im = np.zeros((50, 50)).astype(float) im[:25, :25] = 1. + np.random.seed(seed=1234) im = im + np.random.uniform(size=im.shape) * .2 # Moravec From 5f012cb19dc8fca1149ef581788c18a4277b471d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Thu, 17 Jan 2013 09:07:48 +0100 Subject: [PATCH 5/9] Set random seed value to ensure tests always pass --- skimage/measure/tests/test_structural_similarity.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skimage/measure/tests/test_structural_similarity.py b/skimage/measure/tests/test_structural_similarity.py index ac45072a..ec5ce7ef 100644 --- a/skimage/measure/tests/test_structural_similarity.py +++ b/skimage/measure/tests/test_structural_similarity.py @@ -4,6 +4,9 @@ from numpy.testing import assert_equal, assert_raises from skimage.measure import structural_similarity as ssim +np.random.seed(1234) + + def test_ssim_patch_range(): N = 51 X = (np.random.random((N, N)) * 255).astype(np.uint8) From fcc7edd411ae4babff4ced75d3d6dbc63fe2c80a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Thu, 17 Jan 2013 09:11:21 +0100 Subject: [PATCH 6/9] Set random seed value for denoising tests --- skimage/filter/tests/test_denoise.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/skimage/filter/tests/test_denoise.py b/skimage/filter/tests/test_denoise.py index cb3b5da3..f81ba07b 100644 --- a/skimage/filter/tests/test_denoise.py +++ b/skimage/filter/tests/test_denoise.py @@ -4,6 +4,9 @@ from numpy.testing import run_module_suite, assert_raises, assert_equal from skimage import filter, data, color, img_as_float +np.random.seed(1234) + + lena = img_as_float(data.lena()[:256, :256]) lena_gray = color.rgb2gray(lena) From f78d10c099de66686eb83357502494d266145e57 Mon Sep 17 00:00:00 2001 From: Colin Lea Date: Thu, 17 Jan 2013 11:36:59 -0500 Subject: [PATCH 7/9] Swapped the direection that the histograms point in the hog visualisation --- skimage/feature/_hog.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/feature/_hog.py b/skimage/feature/_hog.py index ce7db462..8e8ea7f2 100644 --- a/skimage/feature/_hog.py +++ b/skimage/feature/_hog.py @@ -142,8 +142,8 @@ def hog(image, orientations=9, pixels_per_cell=(8, 8), centre = tuple([y * cy + cy // 2, x * cx + cx // 2]) dx = radius * cos(float(o) / orientations * np.pi) dy = radius * sin(float(o) / orientations * np.pi) - rr, cc = draw.bresenham(centre[0] - dy, centre[1] - dx, - centre[0] + dy, centre[1] + dx) + rr, cc = draw.bresenham(centre[0] - dx, centre[1] - dy, + centre[0] + dx, centre[1] + dy) hog_image[rr, cc] += orientation_histogram[y, x, o] """ From fe6d3d500cebdf9d0dc51d50adcd35b3918a11d6 Mon Sep 17 00:00:00 2001 From: Christoph Gohlke Date: Fri, 18 Jan 2013 19:48:30 -0800 Subject: [PATCH 8/9] Do not install the doc package --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e1f6c0dc..0040534e 100644 --- a/setup.py +++ b/setup.py @@ -138,7 +138,7 @@ if __name__ == "__main__": configuration=configuration, - packages=setuptools.find_packages(), + packages=setuptools.find_packages(exclude=['doc']), include_package_data=True, zip_safe=False, # the package can run out of an .egg file From 11f32577ab46f4e0010f79239fc61c2486abb59b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Wed, 23 Jan 2013 14:54:33 +0100 Subject: [PATCH 9/9] Fix wrong include paths for shared subpackage --- skimage/draw/setup.py | 2 +- skimage/morphology/setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/skimage/draw/setup.py b/skimage/draw/setup.py index 5b8e237d..1414fca8 100644 --- a/skimage/draw/setup.py +++ b/skimage/draw/setup.py @@ -15,7 +15,7 @@ def configuration(parent_package='', top_path=None): cython(['_draw.pyx'], working_path=base_path) config.add_extension('_draw', sources=['_draw.c'], - include_dirs=[get_numpy_include_dirs(), '../shared']) + include_dirs=[get_numpy_include_dirs(), '../_shared']) return config diff --git a/skimage/morphology/setup.py b/skimage/morphology/setup.py index b8564ce4..1936377b 100644 --- a/skimage/morphology/setup.py +++ b/skimage/morphology/setup.py @@ -29,7 +29,7 @@ def configuration(parent_package='', top_path=None): config.add_extension('_skeletonize_cy', sources=['_skeletonize_cy.c'], include_dirs=[get_numpy_include_dirs()]) config.add_extension('_pnpoly', sources=['_pnpoly.c'], - include_dirs=[get_numpy_include_dirs(), '../shared']) + include_dirs=[get_numpy_include_dirs(), '../_shared']) config.add_extension('_convex_hull', sources=['_convex_hull.c'], include_dirs=[get_numpy_include_dirs()]) config.add_extension('_greyreconstruct', sources=['_greyreconstruct.c'],