Skip to main content

Module hough_transform

Module hough_transform 

Source
Expand description

Hough transform: detecting lines and circles by voting.

Every edge pixel votes for all the shapes that could pass through it; shapes supported by many edge pixels collect many votes and show up as peaks in an accumulator array. This finds shapes even when the edge map has gaps or clutter.

  • Lines use the normal form ρ = x cos θ + y sin θ (with x the column, y the row), θ ∈ [0, π): each pixel votes for one ρ per θ, tracing a sinusoid in (ρ, θ) space. All pixels of a line vote for the same (ρ, θ) cell.
  • Circles of a known radius: each pixel votes for every possible centre on the circle of that radius around it; a true circle’s pixels all vote for its centre.

See the book entry The Hough transform.

Structs§

HoughCircle
A detected circle.
HoughLine
A detected line: all points with x cos θ + y sin θ = ρ.
HoughLines
The line-voting accumulator and its axes.

Functions§

hough_circles
Finds circles with the given candidate radii (pixels). A centre is reported if its votes are at least min_support times the circumference 2πr (try 0.6), strongest first, with centres closer than min_distance pixels suppressed.
hough_line_peaks
Extracts up to max_lines peaks with at least min_votes votes, strongest first. After taking a peak, cells within ±min_rho_bins and ±min_theta_bins (wrapping across θ = 0 ≡ π, where ρ changes sign) are suppressed so one physical line gives one result.
hough_lines
Convenience: the strongest lines in an edge map, with the default resolutions of one degree and one pixel and mild suppression. Returns up to max_lines lines with at least min_votes votes.
hough_transform
Builds the line accumulator for a binary edge map using num_angles angles over [0, π) and a distance resolution of rho_resolution pixels.