mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-05 06:14:18 +08:00
Do not acquire GIL for hough_circle
This commit is contained in:
@@ -79,22 +79,24 @@ def _hough_circle(cnp.ndarray img,
|
||||
|
||||
num_circle_pixels = circle_x.size
|
||||
|
||||
if normalize:
|
||||
incr = 1.0 / num_circle_pixels
|
||||
else:
|
||||
incr = 1
|
||||
with nogil:
|
||||
|
||||
# For each non zero pixel
|
||||
for p in range(num_pixels):
|
||||
# Plug the circle at (px, py),
|
||||
# its coordinates are (tx, ty)
|
||||
for c in range(num_circle_pixels):
|
||||
tx = circle_x[c] + x[p]
|
||||
ty = circle_y[c] + y[p]
|
||||
if offset:
|
||||
acc[i, tx, ty] += incr
|
||||
elif 0 <= tx < xmax and 0 <= ty < ymax:
|
||||
acc[i, tx, ty] += incr
|
||||
if normalize:
|
||||
incr = 1.0 / num_circle_pixels
|
||||
else:
|
||||
incr = 1
|
||||
|
||||
# For each non zero pixel
|
||||
for p in range(num_pixels):
|
||||
# Plug the circle at (px, py),
|
||||
# its coordinates are (tx, ty)
|
||||
for c in range(num_circle_pixels):
|
||||
tx = circle_x[c] + x[p]
|
||||
ty = circle_y[c] + y[p]
|
||||
if offset:
|
||||
acc[i, tx, ty] += incr
|
||||
elif 0 <= tx < xmax and 0 <= ty < ymax:
|
||||
acc[i, tx, ty] += incr
|
||||
|
||||
return acc
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from numpy.testing import assert_almost_equal, assert_equal
|
||||
import skimage.transform as tf
|
||||
from skimage.draw import line, circle_perimeter, ellipse_perimeter
|
||||
from skimage._shared._warnings import expected_warnings
|
||||
from skimage._shared.testing import test_parallel
|
||||
|
||||
|
||||
def append_desc(func, description):
|
||||
@@ -129,6 +130,7 @@ def test_hough_line_peaks_num():
|
||||
min_angle=0, num_peaks=1)[0]) == 1
|
||||
|
||||
|
||||
@test_parallel()
|
||||
def test_hough_circle():
|
||||
# Prepare picture
|
||||
img = np.zeros((120, 100), dtype=int)
|
||||
|
||||
Reference in New Issue
Block a user