From 7337a3e14b09f54985eb9b7878eabf95de95e4fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Tue, 19 May 2015 18:57:20 -0700 Subject: [PATCH] Do not acquire GIL for hough_line --- skimage/transform/_hough_transform.pyx | 19 +++++++++++-------- .../transform/tests/test_hough_transform.py | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/skimage/transform/_hough_transform.pyx b/skimage/transform/_hough_transform.pyx index 601ac0ea..6ce69d8e 100644 --- a/skimage/transform/_hough_transform.pyx +++ b/skimage/transform/_hough_transform.pyx @@ -308,14 +308,17 @@ def hough_line(cnp.ndarray img, # finally, run the transform cdef Py_ssize_t nidxs, nthetas, i, j, x, y, accum_idx - nidxs = y_idxs.shape[0] # x and y are the same shape - nthetas = theta.shape[0] - for i in range(nidxs): - x = x_idxs[i] - y = y_idxs[i] - for j in range(nthetas): - accum_idx = round((ctheta[j] * x + stheta[j] * y)) + offset - accum[accum_idx, j] += 1 + + with nogil: + nidxs = y_idxs.shape[0] # x and y are the same shape + nthetas = theta.shape[0] + for i in range(nidxs): + x = x_idxs[i] + y = y_idxs[i] + for j in range(nthetas): + accum_idx = round((ctheta[j] * x + stheta[j] * y)) + offset + accum[accum_idx, j] += 1 + return accum, theta, bins diff --git a/skimage/transform/tests/test_hough_transform.py b/skimage/transform/tests/test_hough_transform.py index ea9eac42..e7030494 100644 --- a/skimage/transform/tests/test_hough_transform.py +++ b/skimage/transform/tests/test_hough_transform.py @@ -16,6 +16,7 @@ def append_desc(func, description): return func +@test_parallel() def test_hough_line(): # Generate a test image img = np.zeros((100, 150), dtype=int)