?近日把SIFT特征提取及匹配算法推导了一遍,就開始我个人的一个认识吧。
?关于SIFT的算法介绍见最以下的链接。
?假设用SIFT的话。MATLAB的SIFT的code能够学习。个人觉得还是C写的SIFT比較好。
?VLFeat提供C写的SIFT特征提取算法代码,调用例如以下:
//读入图像 char *ImagePath="10011.jpg"; IplImage *Image=cvLoadImage(ImagePath,0); // int min=0; // min=Image->width>Image->height?Image->height:Image->width; //sift特征提取參数设置 int noctaves=4,nlevels=2,o_min=0; // noctaves=(int)(log(min)/log(2)); //载入vlfeat库的sift特征库函数 vl_sift_pix *ImageData=new vl_sift_pix[Image->height*Image->width]; unsigned char *Pixel; for (int i=0;i<Image->height;i++) { for (int j=0;j<Image->width;j++) { Pixel=(unsigned char*)(Image->imageData+i*Image->width+j); ImageData[i*Image->width+j]=*(Pixel); } } VlSiftFilt *SiftFilt=NULL; SiftFilt=vl_sift_new(Image->width,Image->height,noctaves,nlevels,o_min); int KeyPoint=0; int idx=0; if (vl_sift_process_first_octave(SiftFilt,ImageData)!=VL_ERR_EOF) { while (true) { //计算每组中的关键点 vl_sift_detect(SiftFilt); //遍历并绘制每一个点 KeyPoint+=SiftFilt->nkeys; VlSiftKeypoint *pKeyPoint=SiftFilt->keys; for (int i=0;i<SiftFilt->nkeys;i++) { VlSiftKeypoint TemptKeyPoint=*pKeyPoint; pKeyPoint++; cvDrawCircle(Image,cvPoint(TemptKeyPoint.x,TemptKeyPoint.y),TemptKeyPoint.sigma/2,CV_RGB(255,0,0)); idx++; //计算并遍历每一个点的方向 double angles[4]; int angleCount=vl_sift_calc_keypoint_orientations(SiftFilt,angles,&TemptKeyPoint); for (int j=0;j<angleCount;j++) { double TemptAngle=angles[j]; printf("%d: %f\n",j,TemptAngle); //计算每一个方向的描写叙述 float *Descriptors=new float[128]; vl_sift_calc_keypoint_descriptor(SiftFilt,Descriptors,&TemptKeyPoint,TemptAngle); int k=0; //输出128维的值 while (k<128) { printf("%d: %f",k,Descriptors[k]); printf("; "); k++; } printf("\n"); delete []Descriptors; Descriptors=NULL; } } //下一阶 if (vl_sift_process_next_octave(SiftFilt)==VL_ERR_EOF) { // break; } //free(pKeyPoint); KeyPoint=NULL; } } vl_sift_delete(SiftFilt); delete []ImageData; ImageData=NULL; cvNamedWindow("Source Image",1); cvShowImage("Source Image",Image);? ? 假设用OpenCV的话,代码例如以下:
Mat image=imread("1.jpg"); Mat iamgeGray=imread("1.jpg",0); Mat descriptors; vector<KeyPoint> keypoints; SiftFeatureDetector sift2(0.06f,10.0); sift2.detect(iamgeGray,keypoints); drawKeypoints(image,keypoints,image,Scalar(255,0,255)); imshow("test",image); waitKey(); return 0;
SIFT的改进型:
FAST-SIFT (Dom金字塔代替Dog金字塔) ?
PCA-SIFT(降低特征子匹配) ? ? ? ? ? ? ?
上面两种在改进型SIFT特征提取分析见兴许博文。。。。
SIFT特征提取分析相关链接:
http://blog.csdn.net/abcjennifer/article/details/7639681
https://github.com/robwhess/opensift/tree/master/src
http://www.cs.ubc.ca/~lowe/papers/ijcv04.pdf
http://blog.csdn.net/abcjennifer/article/details/7365882
http://en.wikipedia.org/wiki/Scale-invariant_feature_transform#David_Lowe.27s_method
http://blog.sciencenet.cn/blog-613779-475881.html
http://www.cnblogs.com/linyunzju/archive/2011/06/14/2080950.html
http://www.cnblogs.com/linyunzju/archive/2011/06/14/2080951.html
http://blog.csdn.net/ijuliet/article/details/4640624
http://www.cnblogs.com/cfantaisie/archive/2011/06/14/2080917.html?