10 days did not come up to write things, in the process of trial and error in practice, there are too many things to sum up, busy filling bow pit, busy casting resumes (work bowl to). In spite of this, or a little empty to the 10 days in the perfect bag of Words CPP implementation (Stable version 0.01) to do some of the things summed up the process, I hope to be able to have a bit of help later, good to get to the point.
In the word bag model, in order to improve the accuracy of retrieval, you can improve the precision (MAP) by using a lot of trick, one of the most widely used techniques is to rearrange the returned images, and there are many ways to rearrange them, such as merging multiple features at the fractional level (decision making) is also a rearrangement method, But here to do is by eliminating the query image and the candidate image mismatch point to the way to rearrange, eliminate the mismatch is generally used RANSAC algorithm, about the RANSAC principle can be read RANSAC algorithm to do line fitting this article, or the use of Class RANSAC algorithm. As a primary stage of practice, here from the two images of the matching gradually in-depth.
Code Download: The following map of the results of the code can be sift (asift)-match-with-ransac-cpp download. 1NN match
"1NN matching" (not wiki, a self-created vocabulary), speaking more fluently, and should be able to guess from the literal point of view, so it is written here. The so-called "1NN" matching, that is, for a SIFT feature point in the image im1 Point1, through the im2 image of all sift key points to find the most recent point1 key points, repeat the process, you can get the image sift all the feature points in the IM1 matching point ( Nearest neighbor, 1NN). This matching method, there will be a lot of mismatch points, the following is the use of 1NN matching results: From the above figure can be seen, 1NN matching method appears a lot of mismatch points, and these mismatch point to the image retrieval, whether the rearrangement, or image stitching, are not want to see, Therefore, we have to further remove the mismatch point, the following use of "1nn/2nn<0.8" method to remove the mismatch point. 1nn/2nn<0.8
"1nn/2nn<0.8", don't be surprised that you have not seen such a statement, yes, a kind of expression of their own. To the above 1NN method understand, this is a ripe. The so-called "1nn/2nn<0.8", that is, for a certain SIFT feature point in the image im1 Point1, find im2 key points with sift at all point1 key points on the SIFT image ( Remember that the key point point21 to the point1 distance is dis1) and the secondary near key point point22 (the distance to point22 is point1 for this key point), and if dis2, we see it as the correct matching point pair, Otherwise, it will be excluded from the point of mismatch. This method of finding a match is explained by Lowe in its distinctive image features from Scale-invariant keypoints, of course, the 0.8 threshold can be adjusted, but generally use 0.8. The following is the result of matching with this method: it can be seen that after this method match, compared with the "1NN" matching method, compared to "1NN", this method to match a great improvement, but the positive collocation point compared with 1NN has a partial loss. The Ransac method is used to eliminate the mismatch point of these two cases. 1nn+ransac
Back to the previous "1NN" matching point pair, we use the Ransac method to remove the mismatch point, the principle of Ransac method before the relevant article RANSAC algorithm to do straight line fitting, here no longer repeat, Related code see the Findinliers function in Utils.cpp, call is the Cv::findfundamentalmat function in OPENCV to compute its transformation matrix, the following is "1NN" after the Ransac elimination mismatch point pair result: can see, After the Ransac, "1NN" in a lot of mismatch point to almost eliminate the better, but also wrong with the point to not be removed, the picture with a red rectangular box marked with an outstanding mismatch point pair. We're here to see what happens to the "1nn/2nn<0.8" Ransac. 1nn/2nn<0.8+ransac
Before looking at the match result, we may make a approximate forecast first, because "1nn/2nn<0.8" obtains many points is the correct matching point pair, therefore puts it in the RANSAC, can obtain the good fitting model, therefore its elimination mismatch point to effect also should be better. To verify this prediction, let's look at the "1nn/2nn<0.8+ransac" specific effect, as shown in the following illustration: You can see that there is no mismatch at all, from this point of view, the effect is very good. However, from the point of view of the number of positive points, "1NN+RANSAC" The result is more intensive, that is, "1nn+ransac" contains more positive matching point pairs, "1nn/2nn<0.8+ransac" is slightly less than the matching point. In most cases, we will choose to completely eliminate the mismatch pairs of the model.
The above two matching methods are described, respectively, "1NN" and "1nn/2nn<0.8" matching method, and the method of using RANSAC to eliminate mismatch point pairs. Sometimes, if you want to go through the Ransac match to retain more positive point pairs, this time, we can use Affine-sift, referred to as asift, specific can read Asift:an algorithm for fully affine Comparison This article, the author provides asift C + + code and matching algorithm, can be downloaded in Asift, I probably ran a bit inside the demo, compared with Sift,asift can extract a lot of key points, rotation and other transformations have better invariance, But the disadvantage is also very obvious, the speed is too slow, it is difficult to do real-time, so to use the words, the general application in the real time does not require the occasion. I have the OPENCV implementation of the code, you can also try its effect, the OPENCV code implementation from OPENCV Asift C + + IMPLEMENTATION,OPENCV Its Python implementation, easy to use, is too slow, So I am in the image retrieval in the project to write, also do not intend to use it.
For how to apply these matching methods described above to the image retrieval rearrangement, later will do the finishing introduction, today is here, tomorrow Ali written test, Alexander.
From:http://yongyuan.name/blog/sift (Asift)-matching-with-ransac.html