80 likes | 299 Views
Hough Transform. Given marked edge pixels, find examples of specific shapes Line segments Circles Generalized shapes (GHT) Basic idea - Patented 1962 Every edge pixel is a point that votes for all shapes that pass through it. Votes are collected in “parameter space” - look for peaks
E N D
Hough Transform • Given marked edge pixels, find examples of specific shapes • Line segments • Circles • Generalized shapes (GHT) • Basic idea - Patented 1962 • Every edge pixel is a point that votes for all shapes that pass through it. • Votes are collected in “parameter space” - look for peaks • “Parameter space” is a k-dimensional histogram!
Hough Transform for Lines • Parameter space: • Ax+By+C = 0 (But A,B, C aren’t unique!) • Divide by sqrt(A*A+B*B); first two terms are sin,cos of the angle • Angle, distance from 0 • Angle = arctan(A/B), distance = C/(A*A+B*B) • Given a point (x0,y0), find all theta, distance pairs • cos(theta)*x0 + sin(theta)*y0 + distance = 0 • If theta is known (e.g. from Sobel detector), only 1 distance needs to be calculated, otherwise calculate a distance for each theta
Hough Transform for Lines (cont.) • Increment all “cells” in p-space through which curve passes
Hough Transform Example: Line Detecton Image (enlarged) Hough P-Space
Alternative Parametrization for Lines • Number border pixels of the image • For each line segment, store the two border pixels where the (extended) line enters / exits the image • Why? • Values are integers in a fixed range • No trigonometry is needed to find all lines passing through a point
Hough Transform for Circles • Parameter space is (centerx, centery, radius) • Update: • For every point, computer center, radius of all circles passing through the point • Mark each center, radius pair • Alternative computation: for each cell, compute distance from that cell to point - increment if close enough.
GHT: Generalized Hough Transform • Parameters are translation, rotation & scale of a fixed 2D shape,represented as a point set • Given a point and a location in the transform space, if the point is in (or close enough to a point in) the transformed point set, then record a vote.
Hough Transform Issues • Space usage • Need large arrays for accurate results! • More complex objects need more parameters (fast!) • Peak detection • Large spaces take long to search - threshold unreliable • “Accidental peaks” are not unusual • Noise causes “cluster” rather than “peak” - may need to use cluster detection (remember K-means?) • Easily parallelizable!!