Image Filtering with Hough Transforms
Detecting lines and corners with classical vision — Gaussian smoothing, Sobel gradients, the Hough transform, and the Harris corner detector.
╌╌╌╌
This pipeline builds classical edge and feature detection out of convolutions. Given an image, it smooths, estimates gradients, and votes for the geometric structures those gradients imply, lines and corners, all in Python over OpenCV.
Differentiation amplifies high-frequency noise, so Gaussian smoothing convolves the image with a Gaussian kernel first; without it, single-pixel intensity jumps register as spurious edges and swamp the real ones. The Sobel operator then estimates the intensity gradient with a pair of kernels, one per axis, giving at every pixel. Its magnitude measures edge strength and gives the edge orientation. Thresholding the magnitude leaves thick edge bands, so non-maximum suppression thins them: a pixel survives only when its magnitude exceeds both neighbors along the gradient direction, collapsing each band to a one-pixel ridge.
The Hough line transform detects lines even when their pixels are broken or partly occluded. A line is written in normal form,
with the perpendicular distance from the origin and the angle of that perpendicular. This parametrization is bounded and avoids the infinite slope that hits on vertical lines. A fixed edge point swept over traces a sinusoid in space; collinear edge points share one line, so their sinusoids all pass through the single that names it.
Detection becomes counting: quantize into a grid (the accumulator ), and for each edge point add one vote to every cell on its sinusoid. Cells where many sinusoids cross collect high counts, and each such peak is a detected line. Real edges are noisy, so the votes smear across neighboring cells; peaks are recovered by thresholding and then a second non-maximum suppression over , so one line yields one detection instead of a cluster.
- 1input: a set of edge points, an accumulator over quantized
- 2for each point in do
- 3for each in the quantized range do
- 4
- 5
- 6return the cells whose vote count exceeds a threshold
Harris corner detection finds points where intensity changes sharply in every direction. Over a window it forms the second-moment matrix of gradients
and scores each pixel by . Two large eigenvalues — variation along both axes — make large and mark a corner; a single large eigenvalue signals an edge, and neither signals flat texture.
You can read the full report.
References
- Project repository
- Reference notes: Vision and Perception
╌╌ END ╌╌