Sift是David Lowe于1999年提出的局部特征描述子,并于2004年进行了更深入的发展和完善。Sift特征匹配算法可以处理两幅图像之间发生平移、旋转、仿射变换情况下的匹配问题,具有很强的匹配能力。在Mikolajczyk对包括Sift算子在内的十种局部描述子所做的不变性对比实验中,Sift及其扩展算法已被证实在同类描述子中具有最强的健壮性。
总体来说,Sift算子具有以下特性:
(1)Sift特征是图像的局部特征,对平移、旋转、尺度缩放、亮度变化、遮挡和噪声等具有良好的不变性,对视觉变化、仿射变换也保持一定程度的稳定性。
(2)独特性好,信息量丰富,适用于在海量特征数据库中进行快速、准确的匹配。
(3)多量性,即使少数的几个物体也可以产生大量Sift特征向量。
(4)速度相对较快,经优化的Sift匹配算法甚至可以达到实时的要求。
(5)可扩展性强,可以很方便的与其他形式的特征向量进行联合。
Sift特征匹配算法主要包括两个阶段,一个是Sift特征的生成,即从多幅图像中提取对尺度缩放、旋转、亮度变化无关的特征向量;第二阶段是Sift特征向量的匹配。
Sift特征的生成一般包括以下几个步骤:
1、构建尺度空间,检测极值点,获得尺度不变性;
2、特征点过滤并进行精确定位;
3、为特征点分配方向值;

4、生成特征描述子。
以特征点为中心取16*16的邻域作为采样窗口,将采样点与特征点的相对方向通过高斯加权后归入包含8个bin的方向直方图,最后获得4*4*8的128维特征描述子。示意图如下:

当两幅图像的Sift特征向量生成以后,下一步就可以采用关键点特征向量的欧式距离来作为两幅图像中关键点的相似性判定度量。取图1的某个关键点,通过遍历找到图像2中的距离最近的两个关键点。在这两个关键点中,如果次近距离除以最近距离小于某个阙值,则判定为一对匹配点。
一些Sift特征匹配的例子:


FeedBack:
帮忙看一下,关键点定位的部分哪里有问题吗?
[sx,sy]=size(image);
for i=2:sx-1,
for j=2:sy-1,
for n=2:count-2,
neigh=vol0(i-1:i+1,j-1:j+1,n-1:n+1); % (look for maximum or minmum in 26 neighbour points)
minval=min(min(min(neigh)));
maxval=max(max(max(neigh)));
if vol0(i,j,n)==minval
res0{n}(i,j)=1;
end;
if vol0(i,j,n)==maxval
res0{n}(i,j)=1;
end;
[rows,cols]=find( res0{n});% (remove keypoints with low contrast and unstable edge)
for jj=1:length(rows)
r = rows(jj);
c = cols(jj);
D_xx = dog{n}(r,c-1) - 2*dog{n}(r,c) + dog{n}(r,c+1);
D_yy = dog{n}(r-1,c) - 2*dog{n}(r,c) + dog{n}(r+1,c);
D_xy = dog{n}(r,c-1) - dog{n}(r,c) -dog{n}(r-1,c-1) + dog{n}(r-1,c);
D_x=dog{n}(r,c-1)-dog{n}(r,c);
D_y=dog{n}(r-1,c)- dog{n}(r,c);
D_I=dog{n-1}(r,c)-dog{n}(r,c);
D_II=dog{n-1}(r,c)-2*dog{n}(r,c)+dog{n+1}(r,c);
D_xI=dog{n-1}(r,c-1)-dog{n-1}(r,c)-dog{n}(r,c-1)+dog{n}(r,c);
D_yI=dog{n-1}(r-1,c)-dog{n-1}(r,c)-dog{n}(r-1,c)+dog{n}(r,c);
trH = D_xx + D_yy;
detH = D_xx*D_yy - D_xy^2;
Xmax=-inv([D_xx,D_xy,D_xI;D_xy,D_yy,D_yI;D_xI,D_yI, D_II])*[D_x;D_y;D_I]; % (location of keypoint)
for w=1:3
if Xmax(w)>0.5
Xmax(w)=ceil(Xmax(w)); % (interpolate a new value in any direction of location of keyponints)
end
end
Dmax=0.5*[D_xx D_xy D_xI; D_xy D_yy D_yI;D_xI D_yI D_II]'*Xmax+dog{n}(r,c); % (remove keypoints with low contast )
if (trH^2 / detH) > cr | abs(Dmax)<0.03
res0{n}(r,c) = 0;
end;
end;
end
end
end
回复 引用
看看这个函数是不是你需要的.
/*
Interpolates a scale-space extremum's location and scale to subpixel
accuracy to form an image feature. Rejects features with low contrast.
Based on Section 4 of Lowe's paper.
@param dog_pyr DoG scale space pyramid
@param octv feature's octave of scale space
@param intvl feature's within-octave interval
@param r feature's image row
@param c feature's image column
@param intvls total intervals per octave
@param contr_thr threshold on feature contrast
@return Returns the feature resulting from interpolation of the given
parameters or NULL if the given location could not be interpolated or
if contrast at the interpolated loation was too low. If a feature is
returned, its scale, orientation, and descriptor are yet to be determined.
*/
struct feature* interp_extremum( IplImage*** dog_pyr, int octv, int intvl,
int r, int c, int intvls, double contr_thr )
{
struct feature* feat;
struct detection_data* ddata;
double xi, xr, xc, contr;
int i = 0;
while( i < SIFT_MAX_INTERP_STEPS )
{
interp_step( dog_pyr, octv, intvl, r, c, &xi, &xr, &xc );
if( ABS( xi ) < 0.5 && ABS( xr ) < 0.5 && ABS( xc ) < 0.5 )
break;
//TODO:Nic:[070508-Anno1]
/* In libSift, the below condition is added when either xi or xr or xc is >0.5:
* if (xr * xr + xc * xc > 2.0) return NULL;
*/
c += cvRound( xc );
r += cvRound( xr );
intvl += cvRound( xi );//TODO:Nic:[070508-Anno2]In libSift, a peak is rejected if xi>scaleAdjustThresh
if( intvl < 1 ||
intvl > intvls ||
c < SIFT_IMG_BORDER ||
r < SIFT_IMG_BORDER ||
c >= dog_pyr[octv][0]->width - SIFT_IMG_BORDER ||
r >= dog_pyr[octv][0]->height - SIFT_IMG_BORDER )
{
return NULL;
}
i++;
}
/* ensure convergence of interpolation */
if( i >= SIFT_MAX_INTERP_STEPS )
return NULL;
contr = interp_contr( dog_pyr, octv, intvl, r, c, xi, xr, xc );
//TODO:Nic:[070508-Anno4]In libSift, it's like this: [ABS( contr ) < contr_thr]
if( ABS( contr ) < contr_thr / intvls )
return NULL;
//TODO:Nic:[070508-Anno3]
/*
* Since the new peak may shift between coords and level several times, so it may resemble some next peak
* and here it doesn't prevent this case.
*/
feat = new_feature();
ddata = feat_detection_data( feat );
//TODO:Nic:[070508-Anno7]
/*
* feat->x,y,img_pt are converted to sub-pixel & values are relative to 2*original image!
*/
feat->img_pt.x = feat->x = ( c + xc ) * pow( 2.0, octv );
feat->img_pt.y = feat->y = ( r + xr ) * pow( 2.0, octv );
//TODO:Nic:[070508-Anno7]
/*
* r,c are not added with xr,xc, yet major changes(xr or xc>0.5) may have already been made to either or both!
*/
ddata->r = r;
ddata->c = c;
ddata->octv = octv;
//TODO:Nic:[070508-Anno7]
/*
* intvl is not added with xi, yet major changes(xi>0.5) may have already been made to intvl!
*/
ddata->intvl = intvl;
ddata->subintvl = xi;
return feat;
}
回复 引用 查看
Once a complete octave has been
processed, we resample the Gaussian image that has twice the initial value of sigma (it will be 2 images from the top of the stack) by taking every second pixel in each row and column.
我不清楚以上句子的意思。 resize the image (row/2, col/2),
sigma1= 2*sigma (in the new octave)
如何把不同 octave联系起来。 我目前只在一个 octave操作来寻找关键点。
回复 引用
1. 首先个人感觉原文在确定尺度(或者说选取)上的表达有点问题。作者应该明确产生极大值的那一层高斯差分图对应的尺度便是
所需的表达特征最为合适的尺度。这一点原文表达不明确。我找了半天,才勉强找到:在开始部分:At each candidate location, a detailed model is fit to determine location and scale. Keypoints are selected based on measures of their stability.
以及原文3.1中的: It is selected only if it is larger than all of these neighbors or smaller than all of them.
这种不清晰使得我一度以为尺度只是个参数,是人为设定的σ。其实那个基准层的基本尺度,才是人为设定的,作者取值为1.6。作者应该在不同含义的尺度上使用不同的数学符号表达。通篇文章使用的一个词:scale,以及一个数学符号,
其实在不同的地方含义并不同。也不知当初审稿专家是怎么看的,他们没给搞混吗?还是我理解错了?就是一个意思?应该不都是一个意思吧,从其他人的理解以及各方面给出的SIFT介绍看。
2. 关于特征描述子的表达。其使用128维向量的原因是由4×4阵列式的统计8个方向的直方图组成,而每个直方图相应的区域是4×4象素的窗口。这不意味着,不管目标特征的尺度如何,128维向量的相应区域是一样的,即16×16象素的窗口大小,这还能满足尺度不变的要求吗?
比如某图中的目标物和另一图中只有一半大小的同样目标物,即尺度不同。两者采用同样大小的窗口作为某点的局部统计特征用,还能满足尺度不变的要求吗?
从作者的实验看,尺寸小的目标,相应点的统计区域窗口要小些,这说明其与选取的尺度有关,这一点并未在原文中说明,我倒是看到其它介绍SIFT的材料有这样的说明,不知这样理解正确与否?
我们假设尺寸大的目标的那个图像,在某点处,是在第二组octave的某尺度上形成极值,并假设此时的尺度为2σ,σ为当初人为设定的基准层基本尺度。则可以预计,理想情况下,尺寸小的同样目标的同样点会在第一组octave的某尺度形成极值,此时的尺度就是σ,这样才符合统计区域的窗口大小与尺度正比例关系(一些老外的教程就是这么说的),不知这样的理解正确与否?
如果是正确的,作者并未在原文中交代。这可是严重的遗漏,因为这关系着描述子匹配的成败。
还是这方面不需用作说明,因为显然如此?
以上疑问楼主是怎么理解的,能给予点解释吗?我的理解正确吗?在此先谢谢你。
回复 引用
450




被折叠的 条评论
为什么被折叠?



