https://www.zhihu.com/question/23371175
I need to match a photo with the picture in the training set. I took a picture of the eigenvalues and set up a kd tree, and then read the training set of pictures in turn, and then put the features of the picture into the KD tree in order to find the nearest point, the first question is the distance between the 2 points, the direction of the ratio of the length of the ratio in what is a match? The second question is what is the ratio of the matching feature point to the total feature point to the extent that 2 images are matched? The third question is, do we need to find a matching picture to end or traverse all the pictures to find the most matching picture and then end it? Followers 180 viewed 21452Add a commentShareInvitation to answerThe collectionFocus on the issueWrite an Answer3 answersdefault SortChinese cabbage Image Retrieval/Computer vision70 people agreed with the answer
The main question is if you just want to know how sift is matched between two images, here are four matching methods I summed up, hoping to help the master understand the SIFT matching process.
Generally in the word bag model, in order to improve the accuracy of the search, you can use a lot of trick to improve its accuracy (MAP), one of the most widely used technique is to rearrange the returned image, reflow there are many ways, such as multi-feature in the fractional layer (decision-making) fusion is also a rearrangement method, But here to do is to eliminate the query image and candidate image mismatch point of the way to rearrange, eliminate the mismatch is generally used RANSAC algorithm, about RANSAC principle can read RANSAC algorithm to do straight line fitting this article, or the use of Class RANSAC algorithm. As an initial stage of practice, here the match from two images is gradually deepened.
code Download : The code for the results of the map below can be downloaded sift (asift)-match-with-ransac-cpp.
1NN Matching
"1NN match" (not wiki, a self-created word), speak more easily, and literally should be able to guess the meaning of the point, so it is written here. The so-called "1NN" match, that is, for a SIFT feature point in the image im1 Point1, through the im2 image of all sift key points to point1 the closest sift key, repeat the process, you can get all the feature points in the image im1 in im2 matching points ( Nearest neighbor, 1NN). This matching method, there will be a lot of mismatch points, the following is the result of 1NN matching:
As can be seen, the 1NN matching method has a lot of mismatch points, and these mismatches on the image retrieval in the rearrangement, or image splicing, are not want to see, so we have to further the wrong matching point to be rejected, the following use "1nn/2nn<0.8" method to eliminate the mismatch points.
1nn/2nn<0.8
"1nn/2nn<0.8", do not be surprised you have not seen such a statement, yes, their own blind creation of a statement. Understanding the above 1NN method, this is the way to be. The so-called "1nn/2nn<0.8", that is, for a SIFT feature point point1 in an image im1, finds the IM2 key closest to sift by all point1 keys on the SIFT image point21 ( Remember that the key point point21 to point1 distance is dis1) and the second closest key point point22 (remember that the key point point22 to point1 distance of Dis2), if dis1/dis2<0.8, then we see it as the correct matching point pair, Otherwise, the mismatch point pair will be rejected. This search for matching methods is illustrated by Lowe in its distinctive image features from Scale-invariant keypoints, of course, 0.8 this threshold can be adjusted, but generally uses 0.8. The following is the result of matching with this method:
It can be seen that, after this method is matched, compared with the "1NN" matching method, compared to "1NN", this method has a great improvement in matching, but the positive points compared with 1NN partial loss. The Ransac method is used to eliminate the mismatch between the two cases.
1nn+ransac
Back to the front of the "1NN" matching point pair, we then use the Ransac method to the wrong matching point culling, the principle of the Ransac method before the relevant article RANSAC algorithm to do straight line fitting, here no longer repeat, Related code see utils.cpp in the Findinliers function, called the OPENCV in the Cv::findfundamentalmat function to calculate its transformation matrix, the following is "1NN" after the Ransac to eliminate the mismatch pair results:
Can be seen, after the Ransac, "1NN" in a lot of wrong matching point to almost eliminate the relatively good, but also the wrong matching point pair did not eliminate, the figure with a red rectangular box marked the wrong matching point pair. What happens when we take a look at the Ransac of "1nn/2nn<0.8"?
1nn/2nn<0.8+ransac
Before looking at the matching results, we can make a general prediction, because "1nn/2nn<0.8" gets a lot of points is the correct matching of the point pair, so put it into the RANSAC, can get a good fit model, so its elimination mismatch point to the effect should be better. To verify this prediction, let's look at the "1nn/2nn<0.8+ransac" specific effect, as shown in:
As you can see, there is absolutely no mismatch, and from this point on, the effect is very good. However, judging from the number of positive points, the result of "1nn+ransac" is more dense, that is to say "1nn+ransac" contains more positive matching pairs, "1nn/2nn<0.8+ransac" is a little bit less. In most cases, we choose to completely reject the model of mismatch pairs.
Two matching methods are described above, namely "1NN" and "1nn/2nn<0.8" matching methods, and the method of using RANSAC to eliminate mismatch pairs. Sometimes, if the requirements after RANSAC match to retain more positive matching point pair, at this time, we can use Affine-sift, abbreviated ASIFT, specifically can read Asift:an algorithm for Fully affine invariant Comparison This article, the author provides asift C + + code and matching algorithm, can be downloaded in Asift, I probably ran the demo inside, compared with sift,asift can be extracted to a lot of key points, rotation and other transformations have better invariance, However, the shortcomings are also obvious, the speed is too slow, it is difficult to do real-time, so to use, the general application in the real-time do not require the occasion. I have OPENCV implementation of the code, you can also try its effect, the OPENCV code implementation from OPENCV Asift C + + Implementation,opencv its own Python implementation, the use of more convenient, is the speed is too slow, So myself in the image retrieval in the writing project, also do not intend to use it.
--------------------------------------------------------------------------------------------------------------- -----------------------------
Update:
The two days of their own in C + + re-write a method to eliminate the mismatch, the effect is very good:
First come here, there are a lot of pits to fill.
Edited on 2015-08-28 -14 ReviewsShareCollectionThanksThe collectionYang Yansheng more focused to be more free10 people agreed with the answerwrong idea!
Sift characteristics belong to the image local invariance feature, this kind of feature is commonly used for image registration, attention is not the image matching, it is concerned about the image pixel and pixel domain properties, often the same object in different positions and at different times to form the registration of two images.
Image matching generally uses global features, such as color histogram, perceptual hash coding and other characteristics. Posted on 2014-09-06Ten8 ReviewsShareCollectionThanksChen Xi listens more, sees more, says less.Lowe Sift Code online is a lot of Daniel writing code, refer to the good.
How do the
Sift algorithm feature points match?