打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
SIFT特征提取
标签: matlabimage
2012-03-18 10:43 34643人阅读 评论(36) 收藏 举报
分类:

SIFT特征具有缩放、旋转特征不变性,下载了大牛的matlab版SIFT特征提取代码,解释如下:

1.调用方法:

将文件加入matlab目录后,在主程序中有两种操作:

op1:寻找图像中的Sift特征:

[csharp] view plaincopy
  1. [image, descrips, locs] = sift('scene.pgm');   
  2. showkeys(image, locs);  

op2:对两幅图中的SIFT特征进行匹配:

[csharp] view plaincopy
  1. match('scene.pgm','book.pgm');  


由于scene和book两图中有相同的一本书,但orientation和size都不同,可以发现所得结果中Sift特征检测结果非常好。


2.代码下载地址:

http://www.cs.ubc.ca/~lowe/keypoints/
3.想用自己的图片进行调用:
[csharp] view plaincopy
  1. i1=imread('D:\Images\New\Cars\image_0001.jpg');  
  2. i2=imread('D:\Images\New\Cars\image_0076.jpg');  
  3. i11=rgb2gray(i1);  
  4. i22=rgb2gray(i2);  
  5. imwrite(i11,'v1.jpg','quality',80);  
  6. imwrite(i22,'v2.jpg','quality',80);  
  7. match('v1.jpg','v2.jpg');  
experiment results:
scene

book


compare result

EXP2:




C代码:

[cpp] view plaincopy
  1. // FeatureDetector.cpp : Defines the entry point for the console application.  
  2. //  
  3.   
  4. #include "stdafx.h"  
  5. #include "highgui.h"  
  6. #include "cv.h"  
  7. #include "vector"  
  8. #include "opencv\cxcore.hpp"  
  9. #include "iostream"  
  10. #include "opencv.hpp"  
  11. #include "nonfree.hpp"  
  12. #include "showhelper.h"  
  13.   
  14. using namespace cv;  
  15. using namespace std;  
  16.   
  17. int _tmain(int argc, _TCHAR* argv[])  
  18. {  
  19.     //Load Image   
  20.     Mat c_src1 =  imread( "..\\Images\\3.jpg");  
  21.     Mat c_src2 = imread("..\\Images\\4.jpg");  
  22.     Mat src1 = imread( "..\\Images\\3.jpg", CV_LOAD_IMAGE_GRAYSCALE);  
  23.     Mat src2 = imread( "..\\Images\\4.jpg", CV_LOAD_IMAGE_GRAYSCALE);  
  24.     if( !src1.data || !src2.data )  
  25.     { std::cout<< " --(!) Error reading images " << std::endl; return -1; }  
  26.   
  27.     //sift feature detect  
  28.     SiftFeatureDetector detector;  
  29.     std::vector<KeyPoint> kp1, kp2;  
  30.   
  31.     detector.detect( src1, kp1 );  
  32.     detector.detect( src2, kp2 );  
  33.     SiftDescriptorExtractor extractor;  
  34.     Mat des1,des2;//descriptor  
  35.     extractor.compute(src1,kp1,des1);  
  36.     extractor.compute(src2,kp2,des2);     
  37.     Mat res1,res2;   
  38.     int drawmode = DrawMatchesFlags::DRAW_RICH_KEYPOINTS;  
  39.     drawKeypoints(c_src1,kp1,res1,Scalar::all(-1),drawmode);//在内存中画出特征点  
  40.     drawKeypoints(c_src2,kp2,res2,Scalar::all(-1),drawmode);  
  41.     cout<<"size of description of Img1: "<<kp1.size()<<endl;  
  42.     cout<<"size of description of Img2: "<<kp2.size()<<endl;  
  43.   
  44.     BFMatcher matcher(NORM_L2);  
  45.     vector<DMatch> matches;  
  46.     matcher.match(des1,des2,matches);  
  47.     Mat img_match;  
  48.     drawMatches(src1,kp1,src2,kp2,matches,img_match);//,Scalar::all(-1),Scalar::all(-1),vector<char>(),drawmode);  
  49.     cout<<"number of matched points: "<<matches.size()<<endl;  
  50.     imshow("matches",img_match);  
  51.     cvWaitKey();  
  52.     cvDestroyAllWindows();  
  53.   
  54.     return 0;  
  55. }  


Python代码:

http://blog.csdn.net/abcjennifer/article/details/7639681



关于sift的其他讲解:

http://blog.csdn.net/abcjennifer/article/details/7639681

http://blog.csdn.net/abcjennifer/article/details/7372880

http://blog.csdn.net/abcjennifer/article/details/7365882



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
图像配准:基于 OpenCV 的高效实现
特征点检测学习_2(surf算法)
特征点检测学习
php正则提取html img src地址
使用openCV与C++求图片特征值及特征向量并进行图片处理
使用OPENCV自带的sift提取特征
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服