Reputation: 577
This is a bit of a theoretical question, but I was wondering how one randomly chooses points when there are multiple lines to be detected in an image. In most examples I have seen so far, there seems to be only one line to be detected, and it seems easy. However, I am not sure how it is extended to detect multiple lines with a lot more points.
Upvotes: 4
Views: 6706
Reputation: 11785
I think you are operating under a basic misunderstanding. RANSAC is just an algorithm to robustly partition some data points into two classes: those that are well predicted by a given parametric model, and those that aren't. The property of being "well-predicted" is expressed in terms of a loss function ("error") that depends on both the model parameters and the data points.
Reread the above paragraph, then ask yourself: do I have a parametric model expressing a collection of lines? If yes, go ahead and fit it. However, if your model can only handle single lines, you should first segment your dataset into portions that are themselves likely to belong to one line each, and then apply RANSAC to each portion.
In some (easy) cases one can proceed iteratively: first use RANSAC on a one-line model to find a large segment of data that fits one line, remove its segment from the dataset, and iterate on the remaining points.
Upvotes: 10
Reputation: 2191
RANSAC only works well when you want to detect a single inlier model, as Francesco Callari correctly explained. Of course the simple solution would be to use the a "sequential" RANSAC but that does only really work if your lines are mutually exclusive and or can be well constrained, such that RANSAC does really only fit one line instead of spanning multiple ones in an non-optimal manner. To solve this issues there exists a variety of approaches, for instance energy based geometric fitting approaches or using evolutionary dynamics to iteratively determine good candidates, to name two.
Here is a nice introduction to the problem from David F. Fouhey.
Upvotes: 2