From 0586046d59ddbb4b6bad26ef4e11c1be4909fd52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Mon, 22 Apr 2013 21:27:54 +0200 Subject: [PATCH 1/2] fix travis complaint --- skimage/transform/_hough_transform.pyx | 8 +++++++- skimage/transform/tests/test_hough_transform.py | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/skimage/transform/_hough_transform.pyx b/skimage/transform/_hough_transform.pyx index a85bd6c1..73d2d3e2 100644 --- a/skimage/transform/_hough_transform.pyx +++ b/skimage/transform/_hough_transform.pyx @@ -49,6 +49,9 @@ def hough_circle(cnp.ndarray img, if img.ndim != 2: raise ValueError('The input image must be 2D.') + cdef Py_ssize_t xmax = img.shape[0] + cdef Py_ssize_t ymax = img.shape[1] + # compute the nonzero indexes cdef cnp.ndarray[ndim=1, dtype=cnp.intp_t] x, y x, y = np.nonzero(img) @@ -90,7 +93,10 @@ def hough_circle(cnp.ndarray img, for c in range(num_circle_pixels): tx = circle_x[c] + x[p] ty = circle_y[c] + y[p] - acc[i, tx, ty] += incr + if offset: + acc[i, tx, ty] += incr + elif tx < xmax and ty < ymax and tx > 0 and ty > 0: + acc[i, tx, ty] += incr return acc diff --git a/skimage/transform/tests/test_hough_transform.py b/skimage/transform/tests/test_hough_transform.py index 35360e89..5dd47b15 100644 --- a/skimage/transform/tests/test_hough_transform.py +++ b/skimage/transform/tests/test_hough_transform.py @@ -123,7 +123,6 @@ def test_hough_circle(): out = tf.hough_circle(img, np.array([radius])) x, y = np.where(out[0] == out[0].max()) - # Offset for x_0, y_0 assert_equal(x[0], x_0) assert_equal(y[0], y_0) From 67bbf2a537dd66fc243b987fb6fb3df9f2abf712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Boulogne?= Date: Mon, 22 Apr 2013 21:42:16 +0200 Subject: [PATCH 2/2] readability --- skimage/transform/_hough_transform.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skimage/transform/_hough_transform.pyx b/skimage/transform/_hough_transform.pyx index 73d2d3e2..e9a2c575 100644 --- a/skimage/transform/_hough_transform.pyx +++ b/skimage/transform/_hough_transform.pyx @@ -95,7 +95,7 @@ def hough_circle(cnp.ndarray img, ty = circle_y[c] + y[p] if offset: acc[i, tx, ty] += incr - elif tx < xmax and ty < ymax and tx > 0 and ty > 0: + elif 0 <= tx < xmax and 0 <= ty < ymax: acc[i, tx, ty] += incr return acc