如何使用SIFT算法计算两个图像的相似度? [英] How to use SIFT algorithm to compute how similar two images are?

查看:1747
本文介绍了如何使用SIFT算法计算两个图像的相似度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已使用 SIFT 实现href ="http://www.vlfeat.org/overview/sift.html" rel ="noreferrer"> Andrea Vedaldi ,以计算两个相似图像(第二张图像实际上是从不同角度放大的同一对象的放大图片.

I have used the SIFT implementation of Andrea Vedaldi, to calculate the sift descriptors of two similar images (the second image is actually a zoomed in picture of the same object from a different angle).

现在我无法弄清如何比较描述符以判断图像的相似程度?

我知道,除非您之前确实玩过这类事情,否则这个问题是无法回答的,但是我认为以前做过此事的人可能会知道,因此我发布了问题.

I know that this question is not answerable unless you have actually played with these sort of things before, but I thought that somebody who has done this before might know this, so I posted the question.

我做了很少的工作来生成描述符:

the little I did to generate the descriptors:

>> i=imread('p1.jpg');
>> j=imread('p2.jpg');
>> i=rgb2gray(i);
>> j=rgb2gray(j);
>> [a, b]=sift(i);  % a has the frames and b has the descriptors
>> [c, d]=sift(j);

推荐答案

首先,您不应该使用vl_sift而不是sift吗?

First, aren't you supposed to be using vl_sift instead of sift?

第二,您可以使用SIFT功能匹配在两个图像中找到对应关系.这是一些示例代码:

Second, you can use SIFT feature matching to find correspondences in the two images. Here's some sample code:

    I = imread('p1.jpg');
    J = imread('p2.jpg');

    I = single(rgb2gray(I)); % Conversion to single is recommended
    J = single(rgb2gray(J)); % in the documentation

    [F1 D1] = vl_sift(I);
    [F2 D2] = vl_sift(J);

    % Where 1.5 = ratio between euclidean distance of NN2/NN1
    [matches score] = vl_ubcmatch(D1,D2,1.5); 

    subplot(1,2,1);
    imshow(uint8(I));
    hold on;
    plot(F1(1,matches(1,:)),F1(2,matches(1,:)),'b*');

    subplot(1,2,2);
    imshow(uint8(J));
    hold on;
    plot(F2(1,matches(2,:)),F2(2,matches(2,:)),'r*');

vl_ubcmatch()本质上执行以下操作:

vl_ubcmatch() essentially does the following:

假设您在F1中有一个点P,并且想在F2中找到最佳"匹配.一种方法是将F1中的P描述符与D2中的所有描述符进行比较.相比之下,我的意思是找到欧几里得距离(或两个描述符之差的L2-范数).

Suppose you have a point P in F1 and you want to find the "best" match in F2. One way to do that is to compare the descriptor of P in F1 to all the descriptors in D2. By compare, I mean find the Euclidean distance (or the L2-norm of the difference of the two descriptors).

然后,我在F2中找到两个点,比如说U& V,它们与P的距离分别为最低和第二低(例如Du和Dv).

Then, I find two points in F2, say U & V which have the lowest and second-lowest distance (say, Du and Dv) from P respectively.

以下是Lowe的建议:如果Dv/Du> =阈值(我在示例代码中使用1.5),则此匹配是可以接受的;否则,它将被模棱两可地匹配,并且将被拒绝作为对应,并且我们不会将F2中的任何点都匹配到P.本质上,如果最佳匹配和次佳匹配之间存在较大差异,则可以认为这是质量匹配.

Here's what Lowe recommended: if Dv/Du >= threshold (I used 1.5 in the sample code), then this match is acceptable; otherwise, it's ambiguously matched and is rejected as a correspondence and we don't match any point in F2 to P. Essentially, if there's a big difference between the best and second-best matches, you can expect this to be a quality match.

这很重要,因为图像中的歧义匹配存在很大范围:想象一下在湖泊或带有多个窗口的建筑物中的匹配点,描述符看起来可能非常相似,但是对应关系显然是错误的.

This is important since there's a lot of scope for ambiguous matches in an image: imagine matching points in a lake or a building with several windows, the descriptors can look very similar but the correspondence is obviously wrong.

您可以通过多种方式进行匹配..您可以轻松地使用MATLAB自己完成匹配,也可以通过使用KD-tree或近似最近的数字搜索(如 OpenCV .

You can do the matching in any number of ways .. you can do it yourself very easily with MATLAB or you can speed it up by using a KD-tree or an approximate nearest number search like FLANN which has been implemented in OpenCV.

此外,在MATLAB中有几种 kd树实现..

Also, there are several kd-tree implementations in MATLAB.

这篇关于如何使用SIFT算法计算两个图像的相似度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆