170 likes | 381 Views
Hough transform and RANSAC. Further abstraction. Even after edge detection we may have more information than we want. How can we abstract this even further? Choose a parametric object to represent a set of pixels Example: a line (or segment) can represent a set of edge pixels
E N D
Hough transform and RANSAC Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Further abstraction • Even after edge detection we may have more information than we want. • How can we abstract this even further? • Choose a parametric object to represent a set of pixels • Example: a line (or segment) can represent a set of edge pixels • Other possibilities include circles and complex structures Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Fitting • After deciding what representation you are using, there are three main questions: • How many objects are there? • To which of the objects does each pixel belong (if any)? • What parameters best represents each of the objects? Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Curve extraction • One way to extract curves is to link edge pixels together, with junctions indicating breaks. • Can fit curves with model (line, conic section, etc.) after extraction. • However, this doesn’t usually work that well: • Edges are broken by areas of low contrast • Junctions are often missed by edge detectors • Another bad idea: test all possible lines (or other shape). Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Incremental line fitting Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
The Hough transform • The Hough transform is an important method for detecting structure (originally lines, but much more general). • The basic idea is to examine the parameter space for lines, rather than the image space, by mapping pixels in the image into the parameter space. Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Line parameterizations A line is the set of points (x, y) such that: y = mx + b (slope-intercept) or (sin θ) x + (cos θ) y + ρ = 0 (rho-theta) (Two common ways to parameterize a line.) Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
The Hough transform • Different choices of m, b (or q, ρ > 0) give different lines • For any (x, y) there is a one parameter family of lines through this point. • Each point gets to vote for each line in the family; if there is a line that has lots of votes, that should be the line passing through the points Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
ρ y x pixels θ votes Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Construct an array representing q, ρ For each point, render the curve (q, ρ) into this array, adding one at each cell Difficulties: How big should the cells be? If too big, we can’t distinguish between different lines; if too small, noise causes lines to be missed) How many lines? Count the peaks in the array Who belongs to which line? Tag the votes, or post-process Mechanics of the Hough transform Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
ρ y x pixels votes θ Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
ρ y x pixels votes θ Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Hough transform algorithm Construct parameter space voting array (bins). For each edge pixel in image: Increment counter for each bin consistent with pixel. For each bin in voting array: Determine if sufficient votes exist (and local maximum). If so, output line. Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Variations • Can use pairs of points to vote in parameter space • Two points are consistent with only one line • Can use the edge gradient to reduce the number of bins consistent with an edge pixel • One point plus orientation is consistent with only one line • Same ideas can be applied to many other structures: • Circles • Conic sections • Arbitrary 2D shapes • Three-dimensional objects Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson
Choose a small subset uniformly at random Fit the selected subset Anything else that is close to this fit is included Refit Do this many times and choose the best fits Issues How big a subset? Smallest possible How many times? Often enough that we are likely to have a good line How close is “close enough”? Depends on the problem RANSAC Computer Vision Set: Hough transform and RANSAC Slides by D.A. Forsyth, C.F. Olson