SIFT特征提取-应用篇
2016-10-27 11:05
477 查看
原文:http://blog.csdn.net/abcjennifer/article/details/7365882
SIFT特征具有缩放、旋转特征不变性,下载了大牛的matlab版SIFT特征提取代码,解释如下:
1.调用方法:
将文件加入matlab目录后,在主程序中有两种操作:
op1:寻找图像中的Sift特征:
op2:对两幅图中的SIFT特征进行匹配:
由于scene和book两图中有相同的一本书,但orientation和size都不同,可以发现所得结果中Sift特征检测结果非常好。
2.代码下载地址:
http://www.cs.ubc.ca/~lowe/keypoints/
3.想用自己的图片进行调用
book
compare result
EXP2:
C代码
// FeatureDetector.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
#include "vector"
#include "opencv\cxcore.hpp"
#include "iostream"
#include "opencv.hpp"
#include "nonfree.hpp"
#include "showhelper.h"
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//Load Image
Mat c_src1 = imread( "..\\Images\\3.jpg");
Mat c_src2 = imread("..\\Images\\4.jpg");
Mat src1 = imread( "..\\Images\\3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat src2 = imread( "..\\Images\\4.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if( !src1.data || !src2.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
//sift feature detect
SiftFeatureDetector detector;
std::vector<KeyPoint> kp1, kp2;
detector.detect( src1, kp1 );
detector.detect( src2, kp2 );
SiftDescriptorExtractor extractor;
Mat des1,des2;//descriptor
extractor.compute(src1,kp1,des1);
extractor.compute(src2,kp2,des2);
Mat res1,res2;
int drawmode = DrawMatchesFlags::DRAW_RICH_KEYPOINTS;
drawKeypoints(c_src1,kp1,res1,Scalar::all(-1),drawmode);//在内存中画出特征点
drawKeypoints(c_src2,kp2,res2,Scalar::all(-1),drawmode);
cout<<"size of description of Img1: "<<kp1.size()<<endl;
cout<<"size of description of Img2: "<<kp2.size()<<endl;
BFMatcher matcher(NORM_L2);
vector<DMatch> matches;
matcher.match(des1,des2,matches);
Mat img_match;
drawMatches(src1,kp1,src2,kp2,matches,img_match);//,Scalar::all(-1),Scalar::all(-1),vector<char>(),drawmode);
cout<<"number of matched points: "<<matches.size()<<endl;
imshow("matches",img_match);
cvWaitKey();
cvDestroyAllWindows();
return 0;
}
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
SIFT特征具有缩放、旋转特征不变性,下载了大牛的matlab版SIFT特征提取代码,解释如下:
1.调用方法:
将文件加入matlab目录后,在主程序中有两种操作:
op1:寻找图像中的Sift特征:
[image, descrips, locs] = sift('scene.pgm'); showkeys(image, locs);
op2:对两幅图中的SIFT特征进行匹配:
match('scene.pgm','book.pgm');
由于scene和book两图中有相同的一本书,但orientation和size都不同,可以发现所得结果中Sift特征检测结果非常好。
2.代码下载地址:
http://www.cs.ubc.ca/~lowe/keypoints/
3.想用自己的图片进行调用
i1=imread('D:\Images\New\Cars\image_0001.jpg'); i2=imread('D:\Images\New\Cars\image_0076.jpg'); i11=rgb2gray(i1); i22=rgb2gray(i2); imwrite(i11,'v1.jpg','quality',80); imwrite(i22,'v2.jpg','quality',80); match('v1.jpg','v2.jpg');
</pre><pre class="reply-text mb10" style="margin-top:0px; margin-bottom:10px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:0px; white-space:pre-wrap; word-wrap:break-word; zoom:1; line-height:22px; background-color:rgb(255,252,246)" name="code" snippet_file_name="blog_20161027_4_8629807" code_snippet_id="1951584"><span style="font-family:'Microsoft YaHei'; font-size:13px">experiment results:</span>
book
compare result
EXP2:
C代码
// FeatureDetector.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "highgui.h"
#include "cv.h"
#include "vector"
#include "opencv\cxcore.hpp"
#include "iostream"
#include "opencv.hpp"
#include "nonfree.hpp"
#include "showhelper.h"
using namespace cv;
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//Load Image
Mat c_src1 = imread( "..\\Images\\3.jpg");
Mat c_src2 = imread("..\\Images\\4.jpg");
Mat src1 = imread( "..\\Images\\3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
Mat src2 = imread( "..\\Images\\4.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if( !src1.data || !src2.data )
{ std::cout<< " --(!) Error reading images " << std::endl; return -1; }
//sift feature detect
SiftFeatureDetector detector;
std::vector<KeyPoint> kp1, kp2;
detector.detect( src1, kp1 );
detector.detect( src2, kp2 );
SiftDescriptorExtractor extractor;
Mat des1,des2;//descriptor
extractor.compute(src1,kp1,des1);
extractor.compute(src2,kp2,des2);
Mat res1,res2;
int drawmode = DrawMatchesFlags::DRAW_RICH_KEYPOINTS;
drawKeypoints(c_src1,kp1,res1,Scalar::all(-1),drawmode);//在内存中画出特征点
drawKeypoints(c_src2,kp2,res2,Scalar::all(-1),drawmode);
cout<<"size of description of Img1: "<<kp1.size()<<endl;
cout<<"size of description of Img2: "<<kp2.size()<<endl;
BFMatcher matcher(NORM_L2);
vector<DMatch> matches;
matcher.match(des1,des2,matches);
Mat img_match;
drawMatches(src1,kp1,src2,kp2,matches,img_match);//,Scalar::all(-1),Scalar::all(-1),vector<char>(),drawmode);
cout<<"number of matched points: "<<matches.size()<<endl;
imshow("matches",img_match);
cvWaitKey();
cvDestroyAllWindows();
return 0;
}
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
<span style="font-family:Microsoft YaHei;"> </span>
相关文章推荐
- SIFT特征提取-应用篇
- SIFT特征提取-应用篇
- SIFT特征提取-应用篇
- SIFT特征提取-应用篇
- SIFT特征提取分析
- SIFT特征提取分析
- 图像金字塔(pyramid)与 SIFT 图像特征提取(feature extractor)
- SIFT特征提取分析
- SIFT特征提取分析及Opencv API调用
- SIFT特征提取分析
- OpenCV中提取SIFT特征点、图像匹配、图像配准
- SIFT特征提取的GPU实现 SiftGPU: A GPU Implementation of Scale Invariant Feature Transform (SIFT)
- SIFT特征提取分析与实现
- SIFT特征提取算法总结
- SIFT特征提取分析
- SIFT算法学习:特征提取函数的使用
- 图像处理之特征提取(三)之SIFT简单梳理
- sift图像特征提取与匹配算法代码
- 图像特征提取5:SIFT特征
- sift图像特征提取与匹配算法代码