在vs环境中跑动sift特征提取(原理部分)

/*

如果给两张图片,中间有相似点。要求做匹配。怎么做。我现在能讲么?
 
比如给了两幅图片,先求出sift点。
 
尺度空间极值检测。高斯模糊
关键点定位
关键点方向确定
关键点描述
 
kdtree 和 bbf 最优节点优先算法
进行两幅图片特征点的匹配,会涵盖一些不正确的匹配点
 
ransac 随机抽样一致,消除不合适的点
把需要匹配的点,限定到某一个正确的地方
 
根据这种匹配的结果。确定两幅图相交的某一个点。
 
比如两幅图的重叠方式是,左上右下的方式,那么在不重叠的地方,按照左边图像写入,然后全黑。
重叠地方,按照权值进行平滑过渡。左下角的部分涂黑,右下角不重叠的地方按照右图写入。
 

*/

 

慢慢来:

三组共六个文件

imgfeatures.h 和imgfeatures.c 部分

枚举类型1:

feature_type

枚举类型2:

feature_match_type

两组特征颜色

#define FEATURE_OXFD_COLOR CV_RGB(255,255,0)
#define FEATURE_LOWE_COLOR CV_RGB(255,0,255)

述子长度

#define FEATURE_MAX_D 128

特征结构

feature

四个函数:

1、导入特征点

2、导出特征点

3、绘画特征点

4、计算两个述子之间的欧氏距离。

在描述特征点导入时:http://www.robots.ox.ac.uk:5000/~vgg/research/affine/index.html

有这样一个说明

然后是实现

 

导入特征点时:

从文件中读取特征点,文件的组织格式应该是符合牛津视觉几何组的编码形式,或者符合大卫罗尔的编码格式。type这个地方的参数如果是 FEATURE_TYPE 那么她就会被按照牛津特征输入文件的方式对待,也就是牛津视觉几何组,详见http://www.robots.ox.ac.uk:5000/~vgg/research/affine/index.html

断点:仿射协变特征

概述:这个页面针对在任意图片中探测仿射不变特征的问题和区域探测述子的性能评估。【应该就是述子如何描述仿射不变特征,以及述子性能好坏的评估】

公开:

  区域探测:

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/mikolajczyk_ijcv2004.pdf【尺度仿射兴趣点不变检测】

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/matas_bmvc2002.pdf【最稳定极值区域】

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/tuytelaars_ijcv2004.pdf【基于仿射不变区域匹配广域分割场景】

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/kadir04.pdf【放射不变显著区域检测】

All Detectors - SurveyT. Tuytelaars and K. Mikolajczyk , Local Invariant Feature Detectors - Survey. In CVG, 3(1):1-110, 2008.【学名是这个,如果找到的话,求联系~~~】

然后这个第五个文献找不到,希望高玩们可以一同帮忙找下

  区域描述:

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/lowe_ijcv2004.pdf【来自尺度不变关键点的独特图像特征】

  性能评估:

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/vibes_ijcv2004.pdf【仿射区域检测器们的对比】

http://www.robots.ox.ac.uk:5000/~vgg/research/affine/det_eval_files/mikolajczyk_pami2004.pdf【本地述子性能评估】

软件:

  既没有linux,也没有matlab 就不想弄了。。。

测试数据:

  下载一下就可以了

 

imgfeatures.c 就是一些实现的过程。

 

然后看下sift.h这个里面的东西也很简洁,忽然觉得这些东西有点儿像java里面的public函数。.c里面的倒都比较像private函数只能它里面使用。

看下sift.h 里面都有什么

一大堆变量的声明和两个函数

extern int sift_features(IplImage* img, struct feature** feat);

extern int _sift_features(IplImage* img, struct feature** feat, int intvls,
double sigma, double contr_thr, int curv_thr,
int img_dbl, int descr_width, int descr_hist_bins);

并且好像在后面还是调用的关系,毕竟两个的名字十分相像。然后点点点的发现,就是调用的同一个函数。

所以sift的两个文件,就是用来找到sift特征点的。不过要怎么找寻呢。接下来可能就要看这个函数的内容了。

int _sift_features(IplImage* img, struct feature** feat, int intvls,
    double sigma, double contr_thr, int curv_thr,
    int img_dbl, int descr_width, int descr_hist_bins)
{
    IplImage* init_img;
    IplImage*** gauss_pyr, *** dog_pyr;
    CvMemStorage* storage;
    CvSeq* features;
    int octvs, i, n = 0;

    /* check arguments */
    if (!img)
        fatal_error("NULL pointer error, %s, line %d", __FILE__, __LINE__);

    if (!feat)
        fatal_error("NULL pointer error, %s, line %d", __FILE__, __LINE__);

    /* build scale space pyramid; smallest dimension of top level is ~4 pixels */
    init_img = create_init_img(img, img_dbl, sigma);
    octvs = log(MIN(init_img->width, init_img->height)) / log(2) - 2;
    gauss_pyr = build_gauss_pyr(init_img, octvs, intvls, sigma);
    dog_pyr = build_dog_pyr(gauss_pyr, octvs, intvls);

    storage = cvCreateMemStorage(0);
    features = scale_space_extrema(dog_pyr, octvs, intvls, contr_thr,
        curv_thr, storage);
    calc_feature_scales(features, sigma, intvls);
    if (img_dbl)
        adjust_for_img_dbl(features);
    calc_feature_oris(features, gauss_pyr);
    compute_descriptors(features, gauss_pyr, descr_width, descr_hist_bins);

    /* sort features by decreasing scale and move from CvSeq to array */
    cvSeqSort(features, (CvCmpFunc)feature_cmp, NULL);
    n = features->total;
    *feat = calloc(n, sizeof(struct feature));
    *feat = cvCvtSeqToArray(features, *feat, CV_WHOLE_SEQ);
    for (i = 0; i < n; i++)
    {
        free((*feat)[i].feature_data);
        (*feat)[i].feature_data = NULL;
    }

    cvReleaseMemStorage(&storage);
    cvReleaseImage(&init_img);
    release_pyr(&gauss_pyr, octvs, intvls + 3);
    release_pyr(&dog_pyr, octvs, intvls + 2);
    return n;
}

 

posted on 2016-05-29 11:18  木鸟飞  阅读(553)  评论(1编辑  收藏  举报

导航