DEV Community

AC Nice
AC Nice

Posted on • Edited on

Teach me RANSAC Algorithm like I'm 5

I was in a computer vision class when I first heard about the RANSAC algorithm in OpenCV, at first I didn't quite get it, the instructor tried his best though, but I guess I'm a little dumb 😅. Hence my reason for writing this piece so anyone still struggling to figure it out can take deep breath of fresh air 😊.

RANSAC stands for Random Sample Consensus, an effective algorithm used for treating data affected by outliers.

RANSAC is able to treat these kinds of data by grouping the data points into 2 separate categories:

  • The inlier set and
  • The outlier set

By doing this, RANSAC eliminates your concerns of handling outliers. The outliers are simply ignored and now you only have the inlier data points to work with.

Lets have a look at the regression line fitted through the 2D data points.

Image description

You might notice that some of the data points fall in line or close to our fitting line while others fall out. The question now is, how can we separate the inliers from the outliers. You see where the RANSAC algo comes in? 😉😜

The RANSAC algorithm iteratively looks for the best fitting with the highest number of inliers. The fitting point with the highest number of inlier is choosen and that is the basics of what RANSAC is all about.

Conclusion:
Random Sample Consensus is basically a 4 ways procedure of dealing with outliers.

  • Sample a small subset of datapoints and treat them as inliers
  • Take the potential inliers and compute the model parameters
  • Score how many data points supports the fitting.
  • Repeat and take the best fitting score. 😁💃

RANSAC can be applied during image analysis to determine the position and orientation of a robot by analyzing the associated camera images.

My name is AC Nice and I love Computer Vision

Top comments (0)