Search code examples
pythoncomputer-visionimage-stitchingkeypointransac

Why we need to use RANSAC when we already match keypoints?


I am currently working on computer vision program that will stitch images together. I use KAZE algorithm for finding keypoints and describe them. Than I use Brute-force matcher to match them. From this stage I am ready to stitch them I think because I know which point belongs where right? Because I am studing some literature etc. I see they always match keypoints and then use RANSAC which is random? Why use Ransac when I already know which keypoint belong to which done through brute-force matching?

Thank you for answers and have a nice day


Solution

  • RANSAC (and variants) is an algorithm used to robustly fit to the matched keypoints to a mathematical model of the transformation ("warp") from one image to the other, for example, a homography. The keyword here is "robustly": the algorithm tries really hard to identify a large (ideally, the largest) set of matching keypoints that are acceptable, in the sense they agree with each other on supporting a particular value of the model.

    This is done because matched pair of keypoints may be "wrong", either because the matching algorithm screws up (think left eye matched to right eye), or because the matching is correct, but it does not conform to the model (think matches on the same point of a moving car when the two images are taken some time apart). These wrong matches, or "outliers", can (and usually do) throw off the model estimate when the estimation procedure is not robust.