hough_transform.py (scikit-image-0.19.2) | : | hough_transform.py (scikit-image-0.19.3) | ||
---|---|---|---|---|

import numpy as np | import numpy as np | |||

from scipy.spatial import cKDTree | from scipy.spatial import cKDTree | |||

from ._hough_transform import (_hough_circle, | ||||

_hough_ellipse, | from ._hough_transform import _hough_circle, _hough_ellipse, _hough_line | |||

_hough_line, | from ._hough_transform import _probabilistic_hough_line as _prob_hough_line | |||

_probabilistic_hough_line as _prob_hough_line) | ||||

def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10, | def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10, | |||

threshold=None, num_peaks=np.inf): | threshold=None, num_peaks=np.inf): | |||

"""Return peaks in a straight line Hough transform. | """Return peaks in a straight line Hough transform. | |||

Identifies most prominent lines separated by a certain angle and distance | Identifies most prominent lines separated by a certain angle and distance | |||

in a Hough transform. Non-maximum suppression with different sizes is | in a Hough transform. Non-maximum suppression with different sizes is | |||

applied separately in the first (distances) and second (angles) dimension | applied separately in the first (distances) and second (angles) dimension | |||

of the Hough space to identify peaks. | of the Hough space to identify peaks. | |||

skipping to change at line 65 | skipping to change at line 64 | |||

2 | 2 | |||

""" | """ | |||

from ..feature.peak import _prominent_peaks | from ..feature.peak import _prominent_peaks | |||

min_angle = min(min_angle, hspace.shape[1]) | min_angle = min(min_angle, hspace.shape[1]) | |||

h, a, d = _prominent_peaks(hspace, min_xdistance=min_angle, | h, a, d = _prominent_peaks(hspace, min_xdistance=min_angle, | |||

min_ydistance=min_distance, | min_ydistance=min_distance, | |||

threshold=threshold, | threshold=threshold, | |||

num_peaks=num_peaks) | num_peaks=num_peaks) | |||

if a.any(): | if a.size > 0: | |||

return (h, angles[a], dists[d]) | return (h, angles[a], dists[d]) | |||

else: | else: | |||

return (h, np.array([]), np.array([])) | return (h, np.array([]), np.array([])) | |||

def hough_circle(image, radius, normalize=True, full_output=False): | def hough_circle(image, radius, normalize=True, full_output=False): | |||

"""Perform a circular Hough transform. | """Perform a circular Hough transform. | |||

Parameters | Parameters | |||

---------- | ---------- | |||

image : (M, N) ndarray | image : (M, N) ndarray | |||

skipping to change at line 265 | skipping to change at line 264 | |||

Hough transform for line detection", in IEEE Computer Society | Hough transform for line detection", in IEEE Computer Society | |||

Conference on Computer Vision and Pattern Recognition, 1999. | Conference on Computer Vision and Pattern Recognition, 1999. | |||

""" | """ | |||

if image.ndim != 2: | if image.ndim != 2: | |||

raise ValueError('The input image `image` must be 2D.') | raise ValueError('The input image `image` must be 2D.') | |||

if theta is None: | if theta is None: | |||

theta = np.linspace(-np.pi / 2, np.pi / 2, 180, endpoint=False) | theta = np.linspace(-np.pi / 2, np.pi / 2, 180, endpoint=False) | |||

return _prob_hough_line(image, threshold=threshold, line_length=line_length, | return _prob_hough_line(image, threshold=threshold, | |||

line_gap=line_gap, theta=theta, seed=seed) | line_length=line_length, line_gap=line_gap, | |||

theta=theta, seed=seed) | ||||

def hough_circle_peaks(hspaces, radii, min_xdistance=1, min_ydistance=1, | def hough_circle_peaks(hspaces, radii, min_xdistance=1, min_ydistance=1, | |||

threshold=None, num_peaks=np.inf, | threshold=None, num_peaks=np.inf, | |||

total_num_peaks=np.inf, normalize=False): | total_num_peaks=np.inf, normalize=False): | |||

"""Return peaks in a circle Hough transform. | """Return peaks in a circle Hough transform. | |||

Identifies most prominent circles separated by certain distances in given | Identifies most prominent circles separated by certain distances in given | |||

Hough spaces. Non-maximum suppression with different sizes is applied | Hough spaces. Non-maximum suppression with different sizes is applied | |||

separately in the first and second dimension of the Hough space to | separately in the first and second dimension of the Hough space to | |||

identify peaks. For circles with different radius but close in distance, | identify peaks. For circles with different radius but close in distance, | |||

End of changes. 3 change blocks. | ||||

7 lines changed or deleted | | 7 lines changed or added |