{ } Raw JSON

bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / transform / hough_transform / hough_line

function

skimage.transform.hough_transform:hough_line

source: /dev/scikit-image/src/skimage/transform/hough_transform.py :193

Signature

def   hough_line ( image theta = None )

Summary

Perform a straight line Hough transform.

Parameters

image : ndarray of shape (M, N)

Input image with nonzero values representing edges.

theta : ndarray of double, shape (K,), optional

Angles at which to compute the transform, in radians. Defaults to a vector of 180 angles evenly spaced in the range [-pi/2, pi/2).

Returns

hspace : ndarray of uint64, shape (P, Q)

Hough transform accumulator.

angles : ndarray

Angles at which the transform is computed, in radians.

distances : ndarray

Distance values.

Notes

The origin is the top left corner of the original image. X and Y axis are horizontal and vertical edges respectively. The distance is the minimal algebraic distance from the origin to the detected line. The angle accuracy can be improved by decreasing the step size in the theta array.

Examples

Generate a test image:
img = np.zeros((100, 150), dtype=bool)
img[30, :] = 1
img[:, 65] = 1
img[35:45, 35:50] = 1
for i in range(90):
    img[i, i] = 1
rng = np.random.default_rng()
img += rng.random(img.shape) > 0.95
Apply the Hough transform:
out, angles, d = hough_line(img)

Aliases

  • skimage.transform.hough_line