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

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay