Foundations
Hough Transform
Each point votes for possible lines; shared accumulator bins collect evidence for the same hypothesis.
Image space · x right, y up
Selected point 6, x 2, y 5. Sweep angle 45°: 2 points agree at rho 7.0.
Parameter space · θ degrees, signed ρ
Selected point 6, x 2, y 5. Sweep angle 45°: 2 points agree at rho 7.0.
- Image point
- Point vote curve
- Selected point and vote
- Detected line
Move a point. Which lines still have evidence?
The starting six points support three lines: a diagonal, a horizontal, and a vertical. These are point observations — nothing here says which point belongs with which.
Evidence
Point observations propose line hypotheses; they do not specify which line is meaningful.
Check this stage
Check your understanding
Move a point and watch its possible lines become votes. Shared bins collect evidence; changing the threshold changes which hypotheses survive.
Every point proposes lines
The Hough transform counts evidence for line hypotheses. Move point 6 with the coordinate sliders or focus its handle and use the arrow keys. The diamond marks the same observation and its vote in both views. Sparse evidence keeps just two points; Noisy evidence moves one point away from the starting alignment. Reset controls restores all six original observations.
Read the normal angle
This scene uses a bottom-left origin, x increasing rightwards and y upwards. The line equation is . Theta is the angle of the perpendicular normal, not the slope of the line. At zero degrees, rho equals x, so a vertical line has a finite representation. At 90 degrees, rho equals y.
One point traces a sinusoid as theta varies. Points on the same line have curves meeting at its normal angle and signed rho. Signed rho is a coordinate along the chosen normal; its absolute value is the perpendicular distance. The pairs and describe the same undirected line, so a half-turn suffices.
Count bins, not perfect intersections
Sweep the angle in 5-degree steps. Each point votes once per sampled angle into its nearest rho centre. The accumulator has 36 angle columns and 30 rho rows of width 1. Centres run from −15 to 14; the half-open covered extent is [−15.5, 14.5). Exact midpoint ties go towards increasing rho. Votes outside that extent are dropped and counted in Under the hood. The editable [0, 10] image box stays within these bounds.
The readout counts the largest bin at this angle using the actual accumulator. Nearby points can share a bin without being exactly collinear; finer bins can split noisy evidence. Heat opacity is normalised to the current maximum for display. Printed counts and inspection tables retain raw votes.
Thresholds select hypotheses
The starting image has three bins with three votes. Editing it can change that peak. The final stage draws every qualifying bin as a line clipped to the image box. Neighbouring bins can describe similar lines: this lab deliberately applies no peak suppression. Equal-vote rankings are deterministic, ordered by angle then rho.
Predict what a threshold of 7 does, try Reject every hypothesis, then use Back to working to restore all coordinates and controls. With at most six points, seven votes in one bin are impossible. Lowering the threshold admits weaker evidence, including accidental alignments. Two points always define a line, but two votes do not establish that a meaningful edge exists.
Voting is different from regression
Hough voting can retain several line hypotheses, including vertical ones. It does not minimise squared prediction errors or return a single best regression line. A large vote count is evidence under the chosen discretisation, not a probability or certainty estimate. In a full image-processing pipeline, edge detection supplies these point observations first.
The mechanism follows the OpenCV Hough tutorial. The scikit-image example demonstrates the separate peak-selection step used in practical detectors.
Stage recap
Image space
The starting six points support three lines: a diagonal, a horizontal, and a vertical. These are point observations — nothing here says which point belongs with which.
Parameter space
Every possible line through a single point traces a sine curve in (θ, ρ) space — one curve per point. Sweep θ and watch each point’s own candidate ρ move independently.
Voting
Where several curves cross, several points agree on the same line — that crossing is a vote, and the accumulator below counts every one of them over the full sweep. The brightest cells are where the most points agree.
Detection
Keep only the accumulator cells at or above the threshold, then draw the line each one describes back onto the original image. Push the threshold past the true peak and every line disappears — that is this lab’s failure state.
Reference
- Rho (ρ)
- Signed perpendicular coordinate along the normal from the origin
- Theta (θ)
- Angle of that perpendicular from the x-axis
- Line equation
- ρ = x·cos(θ) + y·sin(θ)
- Accumulator
- A count of votes for every (θ, ρ) pair, over every point and every angle
- Detection rule
- Keep (θ, ρ) where votes ≥ threshold, then draw that line back onto the image
Break it on purpose
Set the threshold to 7 to reject every hypothesis from at most six points. Low thresholds admit sparse accidental alignments; a vote count is evidence, not certainty.
Explore next
- Convolution / CNNChange the filter and trace the dot product that builds each cell of the output feature map.
- Image KernelsEach output cell is the sum of the nine pixel–weight products under its window.
- IoU & Non-Max SuppressionIoU measures shared geometry; greedy NMS decides which scored boxes remain under an explicit overlap rule.