資源簡介
這是我在一個(gè)SIFT群里找到的opencv代碼 關(guān)于SIFT檢測特征點(diǎn)以及生成128維描述子向量的全過程講解得很詳細(xì) 基本上每一步都有注釋 只要學(xué)過C++的 應(yīng)該都看得懂 比CSDN上有些理論講解得更清楚 特別是關(guān)于編程的細(xì)節(jié)部分
代碼片段和文件信息
/*
Functions?for?detecting?SIFT?image?features.
For?more?information?refer?to:
Lowe?D.??Distinctive?image?features?from?scale-invariant?keypoints.
International?Journal?of?Computer?Vision?60?2?(2004)
pp.91--110.
Copyright?(C)?2006-2010??Rob?Hess?
Note:?The?SIFT?algorithm?is?patented?in?the?United?States?and?cannot?be
used?in?commercial?products?without?a?license?from?the?University?of
British?Columbia.??For?more?information?refer?to?the?file?LICENSE.ubc
that?accompanied?this?distribution.
@version?1.1.2-20100521
*/
/*
??此文件最重要
??包含SIFT特征點(diǎn)檢測的實(shí)現(xiàn)
*/
#include?“sift.h“
#include?“imgfeatures.h“
#include?“utils.h“
#include?
#include?
/************************?未暴露接口的一些本地函數(shù)的聲明?**************************/
/*************************?Local?Function?Prototypes?*************************/
//將原圖轉(zhuǎn)換為32位灰度圖并歸一化,然后進(jìn)行一次高斯平滑,并根據(jù)參數(shù)img_dbl決定是否將圖像尺寸放大為原圖的2倍
static?IplImage*?create_init_img(?IplImage*?int?double?);
//將輸入圖像轉(zhuǎn)換為32位灰度圖并進(jìn)行歸一化
static?IplImage*?convert_to_gray32(?IplImage*?);
//根據(jù)輸入?yún)?shù)建立高斯金字塔
static?IplImage***?build_gauss_pyr(?IplImage*?int?int?double?);
//對(duì)輸入圖像做下采樣生成其四分之一大小的圖像(每個(gè)維度上減半),使用最近鄰差值方法
static?IplImage*?downsample(?IplImage*?);
//通過對(duì)高斯金字塔中每相鄰兩層圖像相減來建立高斯差分金字塔
static?IplImage***?build_dog_pyr(?IplImage***?int?int?);
//在尺度空間中檢測極值點(diǎn),通過插值精確定位,去除低對(duì)比度的點(diǎn),去除邊緣點(diǎn),返回檢測到的特征點(diǎn)序列
static?CvSeq*?scale_space_extrema(?IplImage***?int?int?double?int?CvMemStorage*);
//通過在尺度空間中將一個(gè)像素點(diǎn)的值與其周圍3*3*3鄰域內(nèi)的點(diǎn)比較來決定此點(diǎn)是否極值點(diǎn)(極大值或極小都行)
static?int?is_extremum(?IplImage***?int?int?int?int?);
//通過亞像素級(jí)插值進(jìn)行極值點(diǎn)精確定位(修正極值點(diǎn)坐標(biāo)),并去除低對(duì)比度的極值點(diǎn),將修正后的特征點(diǎn)組成feature結(jié)構(gòu)返回
static?struct?feature*?interp_extremum(?IplImage***?int?int?int?int?int?double);
//進(jìn)行一次極值點(diǎn)差值,計(jì)算x,y,σ方向(層方向)上的子像素偏移量(增量)
static?void?interp_step(?IplImage***?int?int?int?int?double*?double*?double*?);
//在DoG金字塔中計(jì)算某點(diǎn)的x方向、y方向以及尺度方向上的偏導(dǎo)數(shù)
static?CvMat*?deriv_3D(?IplImage***?int?int?int?int?);
//在DoG金字塔中計(jì)算某點(diǎn)的3*3海森矩陣
static?CvMat*?hessian_3D(?IplImage***?int?int?int?int?);
//計(jì)算被插值點(diǎn)的對(duì)比度:D?+?0.5?*?dD^T?*?X
static?double?interp_contr(?IplImage***?int?int?int?int?double?double?double?);
//為一個(gè)feature結(jié)構(gòu)分配空間并初始化
static?struct?feature*?new_feature(?void?);
//去除邊緣響應(yīng),即通過計(jì)算主曲率比值判斷某點(diǎn)是否邊緣點(diǎn)
static?int?is_too_edge_like(?IplImage*?int?int?int?);
//計(jì)算特征點(diǎn)序列中每個(gè)特征點(diǎn)的尺度
static?void?calc_feature_scales(?CvSeq*?double?int?);
//將特征點(diǎn)序列中每個(gè)特征點(diǎn)的坐標(biāo)減半(當(dāng)設(shè)置了將圖像放大為原圖的2倍時(shí),特征點(diǎn)檢測完之后調(diào)用)
static?void?adjust_for_img_dbl(?CvSeq*?);
//計(jì)算每個(gè)特征點(diǎn)的梯度直方圖,找出其主方向,若一個(gè)特征點(diǎn)有不止一個(gè)主方向,將其分為兩個(gè)特征點(diǎn)
static?void?calc_feature_oris(?CvSeq*?IplImage***?);
//計(jì)算指定像素點(diǎn)的梯度方向直方圖,返回存放直方圖的數(shù)組
static?double*?ori_hist(?IplImage*?int?int?int?int?double?);
//計(jì)算指定點(diǎn)的梯度的幅值magnitude和方向orientation
static?int?calc_grad_mag_ori(?IplImage*?int?int?double*?double*?);
//對(duì)梯度方向直方圖進(jìn)行高斯平滑,彌補(bǔ)因沒有仿射不變性而產(chǎn)生的特征點(diǎn)不穩(wěn)定的問題
static?void?smooth_ori_hist(?double*?int?);
//查找梯度直方圖中主方向的梯度幅值,即查找直方圖中最大bin的值
static?double?dominant_ori(?double*?int?);
//若當(dāng)前特征點(diǎn)的
評(píng)論
共有 條評(píng)論