Quiz: Hough transform for lines

Short questions to test your understanding. Try each on paper first, then open the answer. Lines are written in normal form x\cos\theta + y\sin\theta = \rho, \theta \in [0°, 180°), origin at the image centre, y up.


Q1. What does a single edge point become in the (\theta, \rho) parameter space, and what does that curve represent?

Which lines pass through the point?

A sinusoid \rho(\theta) = x\cos\theta + y\sin\theta. Each point of the curve is one line through the edge point: the curve is the set of all lines that pass through it.


Q2. Why is the slope–intercept form y = mx + c a poor choice of parameters for a Hough accumulator?

What are m and c of a vertical line?

The slope is unbounded: a vertical line has m = \infty, and nearly vertical lines have very large m and c. A finite grid of bins over (m, c) cannot contain all lines. The normal form has \theta \in [0°, 180°) and |\rho| at most half the image diagonal, so a finite grid covers every line.


Q3. A line is drawn as a dashed line: only every other group of 10 pixels is present. Compared with the solid line, what happens to its peak in the accumulator?

Each point votes independently.

The peak stays at the same (\theta, \rho) and has about half the height (half as many edge points vote for it). The gaps themselves do not matter; only the number of points on the line does. If half the height is still above the threshold, the line is found.


Q4. Without non-maximum suppression, a single straight edge gives several detections. Why?

Do all votes of one line land in exactly one bin?

Edge positions are rounded to pixels and slightly noisy, and the grid is discrete, so the votes of one line spread over a few neighbouring (\theta, \rho) bins. Several of them exceed the threshold, and each becomes a nearly identical line. NMS keeps only the bin that is the maximum in its neighbourhood.


Q5. You make the bins ten times finer to measure the angle of a line more precisely, and the line is no longer detected. What happened?

How many votes does each small bin get?

The edge points of a real line are not exactly collinear. With very small bins their votes spread over many bins, so no single bin reaches the threshold: the peak dissolves. Bins should be about as large as the scatter of the votes (about 1 px in \rho and a fraction of a degree to a degree in \theta). For more precision, refine the peak afterwards, for example by fitting a line to the points that voted for it.


Q6. An edge point has gradient direction 30°. With gradient voting, for which lines does it vote? Why does this reduce false detections in clutter?

How is the gradient related to the direction of the edge?

The gradient is perpendicular to the edge, so it is the normal of the line the point lies on: the point votes only for \theta \approx 30° (within a small window), at its own \rho. A random clutter point now casts a few votes instead of one per angle, and for a bin to collect many votes the points must be collinear and have gradients perpendicular to that line. Chance alignments of clutter rarely satisfy both.


Q7. (math) Show that the curves of two different points (x_1, y_1) and (x_2, y_2) cross at the \theta whose normal is perpendicular to (x_2 - x_1, y_2 - y_1).

Subtract the two equations \rho = x_i\cos\theta + y_i\sin\theta.

At a crossing both give the same \rho: (x_1 - x_2)\cos\theta + (y_1 - y_2)\sin\theta = 0, i.e. (\cos\theta, \sin\theta) \cdot (\mathbf p_1 - \mathbf p_2) = 0. The normal is perpendicular to the difference of the points, so the line with this normal and \rho = x_1\cos\theta + y_1\sin\theta contains both points. In [0°, 180°) there is exactly one such \theta.


Q8. How are the Hough transform for lines and the Radon transform related?

What is the integral of a binary edge image along a line?

The Radon transform integrates an image along every line (\theta, \rho). For a binary edge image this integral counts the edge pixels on the line, which is the number of votes in the Hough bin (\theta, \rho). The Hough accumulator is a discretised Radon transform of the edge map; the Hough transform looks for its peaks, while the Radon day uses it for reconstruction.