lowe sift matlab代码解释,SIFT算法:Matlab程序代码测试例子的说明(Lowe的代码)

the UCLA Ph.D program.

Popular code

Collaborators

Stefano Soatto, University of California at Los Angeles, Los Angeles, USA.

Serge Belongie, University of California at San Diego, San Diego, USA.

Paolo Favaro, Heriot-Watt University, Riccarton, Edinburgh, UK.

Hailin Jin, Adobe System Incorporated, California, USA.

Andrew Rabinowich, University of California at San Diego, San Diego, USA.

Gregorio Guidi, University of California at Los Angeles, Los Angeles, USA.

Brian Fulkerson, University of California at Los Angeles, Los Angeles, USA.

3 以后陆续有许多基于Sift算法实现图像目标匹配和目标识别等方面的应用,大多都是基于上述的代码和

算法原理来进行的。

关于第一测试代码的说明:

1 共有三段Matlab代码源文件

match.m:测试程序

功能:该函数读入两幅(灰度)图像,找出各自的 SIFT 特征, 并显示两连接两幅图像中被匹配的特

征点(关键特征点(the matched keypoints)直线(将对应特征点进行连接)。判断匹配的准则是匹配

距离小于distRatio倍于下一个最近匹配的距离( A match is accepted only if its distance is less than

distRatio times the distance to the second closest match.

该程序返回显示的匹配对的数量。( It returns the number of matches displayed.)

调用实例: match('desk.jpg','book.jpg');

( 假如,想测试一个含有一本书的桌面的图像 和一本书的图像之间特征匹配)

调用方法和参数描述:略。

注意:(1)图像为灰度图像,如果是彩色图像,应该在调用前利用rgb2gray转换为灰度图像。

(2)参数distRatio 为控制匹配点数量的系数,这里取 0.6,该参数决定了匹配点的数量,在

Match.m文件中调整该参数,获得最合适的匹配点数量。

sift.m :尺度不变特征变换(SIFT算法)的核心算法程序

具体原理详见David G. Lowe发表于2004年Int Journal of Computer Vision,2(60):91-110的那篇标题

为“Distivtive Image Features from Scale -Invariant Keypoints" 的论文

功能:该函数读入灰度图像,返回SIFT 特征关键点( SIFT keypoints.)

调用方法和参数描述:

调用方式:[image, descriptors, locs] = sift(imageFile)

输入参数( Input parameters):

imageFile: 图像文件名.

输出或返回参数( Returned):

image: 是具有double format格式的图像矩阵

descriptors: 一个 K-by-128 的矩阵x, 其中每行是针对找到的K个关键特征点(the K keypoints)

的不变量描述子. 这个描述子(descriptor)是一个拥有128个数值并归一化为单位长度向量.

locs: 是K-by-4 矩阵, 其中的每一行具有四个数值,表示关键点位置信息 (在图像中的行坐标,列坐

标(row, column) ,注意,一般图像的左上角为坐标原点), 尺度scale,高斯尺度空间的参数,其中该参

数也决定了frame(结构)确定的图像disk的大小, 最后一个参数是方向orientation). 方向参数的范围是

[-PI, PI] 单位为弧度.

%

appendimages.m:    该函数创建一个新的图像分别包含两个匹配的图像和他们之间的匹配对的

连接直线.

2、测试结果

输入图像1:book1gray.jpg

0818b9ca8b590ca3270a3433284dd417.png

输入图像2:book2gray.jpg

0818b9ca8b590ca3270a3433284dd417.png

运行结果1:(比例参数为0.6 )

调用过程: match('book1gray.jpg','book2gray.jpg')

输出结果:

Finding keypoints...

394 keypoints found.   (第1幅图像中检测到394个特征点)

Finding keypoints...

488 keypoints found. (第2幅图像中检测到488个特征点)

Found 82 matches.  (找到了82个匹配点)

ans =

82

0818b9ca8b590ca3270a3433284dd417.png

运行结果2:(比例参数为0 . 5 )

调用过程: match('book1gray.jpg','book2gray.jpg')

输出结果:

Finding keypoints...

394 keypoints found.   (第1幅图像中检测到394个特征点)

Finding keypoints...

488 keypoints found. (第2幅图像中检测到488个特征点)

Found 55 matches.  (找到了55个匹配点)

0818b9ca8b590ca3270a3433284dd417.png

运行结果3 把第二个测试图像变成其中的一个局部,如图 (book2graypart.jpg)

0818b9ca8b590ca3270a3433284dd417.png

参数同上,比例参数为0 . 5

调用过程: match('book1gray.jpg','book2graypart.jpg')

Finding keypoints...

394 keypoints found.

Finding keypoints...

121 keypoints found.

Found 26 matches.

ans =

26

0818b9ca8b590ca3270a3433284dd417.png

1 在Matlab环境调用主函数

match('book1gray.jpg','book2gray.jpg')

2 注意,必须使matlab 的当前工作文件夹设置成你当前的文件夹

3 这个match 中,增加了 shoukeys的调用,可以显示每个图像全部的关键特征点矢量信息。

0818b9ca8b590ca3270a3433284dd417.png

回复hrr1109:

1 关于匹配点的像素坐标

参考源程序文档被Match.m调用的Sift.m,其调用格式为

[image, descriptors, locs] = sift(imageFile),

所以,在Match.m中最前面返回的Locs参数就保留了进行匹配的两个图像所以的特征点的坐标信息:

(locs: K-by-4 matrix, in which each row has the 4 values for a keypoint location (row, column, scale, orientation). The orientation is in the range [-PI, PI] radians.)

你可以在Match.m源程序中,在最后找到匹配点联线的循环语句:

for i = 1: size(des1,1)

if (match(i) > 0)

line([loc1(i,2) loc2(match(i),2)+cols1], ...

[loc1(i,1) loc2(match(i),1)], 'Color', 'c');

end

end

凡是Match数组不为零的,其下表i 和本身的值match(i) 就是对应的结果信息(索引坐标数组的)。

2 关于Matlab文件保存

请参考: Matlab中的保存数据语句比较

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值