460 likes | 613 Views
Grouping and Segmentation. Sometimes edge detectors find the boundary pretty well. Sometimes it’s not enough. Improve Boundary Detection. Integrate information over distance. Piece together curve fragments from Edge Detector into longer curves Get User to Help?.
E N D
Improve Boundary Detection • Integrate information over distance. • Piece together curve fragments from Edge Detector into longer curves • Get User to Help?
Canny edges Can we find the long straight lines from result of edge detection?
Hough Transform Can we detect this straight line?
Hough Transform All possible lines going through given image points
Hough Transform All possible lines going through given image points Each image point gives one curve (showing all lines through that point)
Hough Transform All possible lines going through given image points
Hough Transform All possible lines going through given image points
Hough Transform All possible lines going through given image points
Hough Transform All possible lines going through given image points
Hough Transform All possible lines going through given image points Each image point gives one curve (showing all lines through that point) This line passes through every image point
Hough Transform All possible lines going through given image points • Idea • Each image point votes for all • lines passing through it. • All points on a line vote for it, • so it gets many votes and stands out
Hough Transform All possible lines going through given image points • Idea • Each image point votes for all • lines passing through it. • All points on a line vote for it, • so it gets many votes and stands out Accumulate votes in bins
Hough Transform All possible lines going through given image points Line with most votes (all 21 pts) Accumulate votes in bins
Hough Transform Noisy line
Hough Transform Noisy line
Hough Transform Noisy line Winning bin has 18/21 votes
Hough Transform No line, just random points
Hough Transform No line, just random points
Hough Transform No line, just random points
Hough Transform No line, just random points Still 7 votes!
HoughTransform Both line and random points
HoughTransform Both line and random points
HoughTransform Both line and random points
HoughTransform Both line and random points Still many bins with over 10 votes Histogram of vote numbers
HoughTransform Lines for bins with 10 or more votes
Hough Transform Problems • Bin size chosen too big: • Inaccurate lines • Can’t distinguish very different lines • Get fake lines from noise • Bin size chosen too small: • Too few votes per bin, can miss the true lines • How many lines? Where to set the cutoff on vote number?
Edge detection Votes All lines through edge points
Top 10 lines (most votes) • Why aren’t the straight lines detected? • Too much noise • Lines are too short • (longer lines through noise points • accumulate more votes) • We didn’t consider gradient direction
Hough Transform: Robust Statistics • Fitting a line in noise
Hough Transform: Robust Statistics • Fitting a line in noise Line points: Inliers
Hough Transform: Robust Statistics • Fitting a line in noise Unrelated random noise: outliers Noisy line points: Inliers
Hough Transform: Robust Statistics • Fitting a line in noise • Very important problem in vision and elsewhere
Hough Transform: Robust Statistics • Fitting a line in noise • Can’t use least squares to fit line to points: which points to fit??? Reminder least-squares fit (for best line): find a,b that minimize
Hough Transform: Robust Statistics • Fitting a line in noise • Hough transform solves this problem.
Hough Transform: Robust Statistics • Hough transform • Fitting a line or other structures (circle, rectangle, figure eight…) in noise • BUT Hough often works badly • Too sensitive to parameter choices • Can miss lines or find wrong ones • Better for finding very constrained structures Eg, Vertical figure eights of known size, 2 perfect aligned equal circles… • Better solution for finding structures in noise: RANSAC
RANSAC for lines • Finding a line in noise: RANSAC For K iterations: Choose two data points randomly. Compute the line passing through them. Count all data points within threshold distance D of this line. If Count larger than C, Store data points close to line. Use least-squares fit to find best line through these points. Store this line. Choose line giving largest Count. (Or, line with smallest least-squares error in fit to its set of close points)
RANSAC for lines • Finding a line in noise: RANSAC For K iterations: Choose two data points randomly. Compute the line passing through them. Count all data points within threshold distance D of this line. If Count larger than C, Store data points close to line. Use least-squares fit to find best line through these points. Store this line. Choose line giving largest Count. (Or, line with smallest least-squares error in fit to its set of close points) • Why does it work? After K iterations, chance of choosing a bad point each time: is fraction of “good” points in data set.
RANSAC for lines • Finding a line in noise: RANSAC For K iterations: Choose two data points randomly. Compute the line passing through them. Count all data points within threshold distance D of this line. If Count larger than C, Store data points close to line. Use least-squares fit to find best line through these points. Store this line. Choose line giving largest Count. (Or, line with smallest least-squares error in fit to its set of close points) • Why does it work? After K iterations, chance of choosing a bad point each time: is fraction of “good” points in data set. so chance of RANSAC success = 99.7%
RANSAC for lines • Finding a line in noise: RANSAC For K iterations: Choose two data points randomly. Compute the line passing through them. Count all data points within threshold distance D of this line. If Count larger than C, Store data points close to line. Use least-squares fit to find best line through these points. Store this line. Choose line giving largest Count. (Or, line with smallest least-squares error in fit to its set of close points) • Many variations, related algorithms Preemptive RANSAC, MLESAC,…