"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "skimage/transform/tests/test_hough_transform.py" between
scikit-image-0.19.2.tar.gz and scikit-image-0.19.3.tar.gz

About: scikit-image is a collection of algorithms for image processing in Python.

test_hough_transform.py  (scikit-image-0.19.2):test_hough_transform.py  (scikit-image-0.19.3)
import numpy as np import numpy as np
import pytest import pytest
from numpy.testing import assert_almost_equal, assert_equal from numpy.testing import assert_almost_equal, assert_equal
from skimage import data, transform
from skimage._shared.testing import test_parallel from skimage._shared.testing import test_parallel
from skimage import data from skimage.draw import circle_perimeter, ellipse_perimeter, line
from skimage import transform
from skimage.draw import line, circle_perimeter, ellipse_perimeter
@test_parallel() @test_parallel()
def test_hough_line(): def test_hough_line():
# Generate a test image # Generate a test image
img = np.zeros((100, 150), dtype=int) img = np.zeros((100, 150), dtype=int)
rr, cc = line(60, 130, 80, 10) rr, cc = line(60, 130, 80, 10)
img[rr, cc] = 1 img[rr, cc] = 1
out, angles, d = transform.hough_line(img) out, angles, d = transform.hough_line(img)
skipping to change at line 56 skipping to change at line 55
img[100 - i, i] = 100 img[100 - i, i] = 100
img[i, i] = 100 img[i, i] = 100
# decrease default theta sampling because similar orientations may confuse # decrease default theta sampling because similar orientations may confuse
# as mentioned in article of Galambos et al # as mentioned in article of Galambos et al
theta = np.linspace(0, np.pi, 45) theta = np.linspace(0, np.pi, 45)
lines = transform.probabilistic_hough_line( lines = transform.probabilistic_hough_line(
img, threshold=10, line_length=10, line_gap=1, theta=theta) img, threshold=10, line_length=10, line_gap=1, theta=theta)
# sort the lines according to the x-axis # sort the lines according to the x-axis
sorted_lines = [] sorted_lines = []
for line in lines: for ln in lines:
line = list(line) ln = list(ln)
line.sort(key=lambda x: x[0]) ln.sort(key=lambda x: x[0])
sorted_lines.append(line) sorted_lines.append(ln)
assert([(25, 75), (74, 26)] in sorted_lines) assert([(25, 75), (74, 26)] in sorted_lines)
assert([(25, 25), (74, 74)] in sorted_lines) assert([(25, 25), (74, 74)] in sorted_lines)
# Execute with default theta # Execute with default theta
transform.probabilistic_hough_line(img, line_length=10, line_gap=3) transform.probabilistic_hough_line(img, line_length=10, line_gap=3)
def test_probabilistic_hough_seed(): def test_probabilistic_hough_seed():
# Load image that is likely to give a randomly varying number of lines # Load image that is likely to give a randomly varying number of lines
image = data.checkerboard() image = data.checkerboard()
skipping to change at line 112 skipping to change at line 111
testim[50:100, 20] = True testim[50:100, 20] = True
testim[20:225, 25] = True testim[20:225, 25] = True
testim[15:35, 50] = True testim[15:35, 50] = True
testim[1:-1, 58] = True testim[1:-1, 58] = True
hough_space, angles, dists = transform.hough_line(testim) hough_space, angles, dists = transform.hough_line(testim)
hspace, _, _ = transform.hough_line_peaks(hough_space, angles, dists) hspace, _, _ = transform.hough_line_peaks(hough_space, angles, dists)
assert hspace[0] > hspace[1] assert hspace[0] > hspace[1]
def test_hough_line_peaks_single_line():
# Regression test for gh-6187, gh-4129
# create an empty test image
img = np.zeros((100, 100), dtype=bool)
# draw a horizontal line into our test image
img[30, :] = 1
hough_space, angles, dist = transform.hough_line(img)
best_h_space, best_angles, best_dist = transform.hough_line_peaks(
hough_space, angles, dist
)
assert len(best_angles) == 1
assert len(best_dist) == 1
expected_angle = -np.pi / 2
expected_dist = -30
assert abs(best_angles[0] - expected_angle) < 0.01
assert abs(best_dist[0] - expected_dist) < 0.01
def test_hough_line_peaks_dist(): def test_hough_line_peaks_dist():
img = np.zeros((100, 100), dtype=bool) img = np.zeros((100, 100), dtype=bool)
img[:, 30] = True img[:, 30] = True
img[:, 40] = True img[:, 40] = True
hspace, angles, dists = transform.hough_line(img) hspace, angles, dists = transform.hough_line(img)
assert len(transform.hough_line_peaks(hspace, angles, dists, assert len(transform.hough_line_peaks(hspace, angles, dists,
min_distance=5)[0]) == 2 min_distance=5)[0]) == 2
assert len(transform.hough_line_peaks(hspace, angles, dists, assert len(transform.hough_line_peaks(hspace, angles, dists,
min_distance=15)[0]) == 1 min_distance=15)[0]) == 1
 End of changes. 4 change blocks. 
7 lines changed or deleted 26 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)