1

When homograpgy matrix with RANSAC is calculated with less numbers of matched keypoints(>4), the transformed image with warpPerspertive, is somehow distorted or tilted. when same image is used to warp with more number of matched keypionts, the result are good. I saw a similar question here but it is still unsolved.

Theoritically we need only 4 matched keypoints, but in parctical why it doesn't work? Can anybody please explain or provide some paper which explains the reasons behind.

Thanks

Community
  • 1
  • 1
MMH
  • 1,676
  • 5
  • 26
  • 43
  • you are probably not in the right place to ask this question, try some image processing forums i bet they'll help much better – chouaib Apr 03 '14 at 08:35
  • are you sure that all the keypoint correspondences are valid? `findHomography` uses RANSAC method to find outlier within the correspondences. RANSAC assumes to have some percentage of inlier, so if you have few keypoints this percentage might not hold anymore. I recommend to implement your own `findHomography` with RANSAC to have more control about the behaviour. – Micka Apr 03 '14 at 08:44
  • @chouaib, thanks, I have also asked in opencv forum. – MMH Apr 03 '14 at 08:49
  • @Micka you mean I should calculate the homography matrix manually? And yes keypoint matching is also done with RANSAC, so the matching results are good. – MMH Apr 03 '14 at 08:50
  • how is the matching done with RANSAC? RANSAC is used during homography computation afaik. Matching is before homopgraphy computation and defines the correspondences between keypoints. Normally, some of them are good/correct and others are false. - you can use OpenCV to compute a homography from 4 keypoint correspondences, what I mean is to use that functionality to implement your own RANSAC which expands a 4-correspondences-homography to a best-number-of-inlier-correspondences homography or rejects the 4-corresp-hom. http://www.inf.u-szeged.hu/~kato/teaching/computervision/Lab05-RANSAC.pdf – Micka Apr 03 '14 at 09:06
  • Hi @Micka, thanks for your comment. matchingcan be done with RANSAC to remove the outlier matching points. You can find an example in the opencv 2.2 cookbook. – MMH Apr 04 '14 at 01:53
  • @MMH afaik it is not the matching that is done with RANSAC but the homography computation. – Micka Apr 04 '14 at 06:11
  • @Micka, before estimating the homography matrix, we can use RANSAC to remove outlier matches. and I am 100% sure about it please refer to "OpenCV.2.Computer.Vision.Application.Programming.Cookbook" for more details. – MMH Apr 04 '14 at 06:40
  • @MMH the cookbook says that RANSAC is used DURING homography computation (I guess you don't compute a fundamental matrix?) and not during matching, just as I assumed (page 243). Since findHomography returns the inliers too, you can easily check whether the inliers are ok and spread over the image, or concentrated to too small areas of the image (and maybe still contain outlier). – Micka Apr 04 '14 at 07:04
  • Please check page 234, I think this discussion in not meaning full at this point, I am having different problem. thanks – MMH Apr 04 '14 at 07:20
  • @MMH page 234 is about fundamental matrix computation. If you use that code, what is your parameter value for `confidence level`? And if you use `findHomography`, did you check the `inlier` return value whether there are still outlier within the used inlier? As said in the book (233): "However, to be able to check this condition, the fundamental matrix must be known, and we need good matches to estimate this matrix. This seems to be a chicken-and-egg problem. We propose in this recipe a solution in which the fundamental matrix and a set of good matches will be jointly computed." – Micka Apr 04 '14 at 07:38
  • in addition: if you use that "robust matcher", you need at least 5 good correspondences (since it computes the fundamental matrix). – Micka Apr 04 '14 at 07:39

1 Answers1

2

One big part of the problem is that we have limited precision in an image. Many algorithms make use of sub-pixel accuracy, but it is difficult to find the exact location for a wide variety of reasons. Just a few are that visual information is lost by discretizing a scene into pixels, differences in image resolution, camera sensor imperfections and characteristics, lighting changes, etc.

Consider the 1D case. Say we have two points that are supposed to placed at the exact locations 0 and 20.5, but instead are found at 0 and 20. This is a 2.5% error. If those points were used to transform an 1D image of size 500, some pixels can be off by 12.5 pixels. These errors have a very large effect in parts of the image far away from the correspondences we found. This is called a measurement error.

Obviously if we have one bad correspondence the homography will be bad. These bad matches are called a classification error. In practice we cannot count on any four matches to be perfectly correct that were generated using any of the OpenCV point descriptors. We can (depending on the scene and set up) count on many points to be close to correct.

Take a look at Random Sample Consensus: A Paradigm for Model Fitting with Applications to Image Analysis and Automated Cartography by Fishler and Bolles. It describes an algorithm similar to RANSAC in OpenCV. It discusses briefly the effect of classification and measurement errors. It says that measurement errors typically follow a normal distribution so if we have many matches, measurement errors will have minimal effect. We can also find a way to determine which matches are likely to be a classification error and minimize their effect.

Danny
  • 2,221
  • 2
  • 18
  • 21
  • Hi @Danny, thanks for your answer. let me go though the paper you mentioned. I really need to know why homography with RANSAC doesn't gives good results with less number of matches.. – MMH Apr 04 '14 at 02:00
  • I understand your explanation. Thanks for that But did not find any solution for the problem. in the paper they says, measurement error can be minimized by RANSAC, but even though we are using RANSAC to find the homography matrix, they results are bad.. – MMH Apr 04 '14 at 05:40
  • Well the measurement error can only be minimized with many points. Depending on the application I think I have used up to 100 to 1000 point correspondences and achieved great results. I have also actually tried using <10 point correspondences that seemed easy to accurately locate and I had a similar experience to what it sounds like you are having. The homography calculation is very sensitive to small errors – Danny Apr 04 '14 at 10:28