A1:笑得海潮 B3:冒泡的崔 D2:Cornell University,Computer Vision Group H2:冰河的博客 G3:丕子博客 K1:MLA CHINA K4:斯坦福视觉实验室 L4:MIT 机器学习实验室
现在的位置: 首页技术, 科研>正文
cat_ico23 category cat_ico37 category
SIFT算法一点小资料
发表于850 天前 技术, 科研 评论数 6 ⁄ 被围观 1,992 次+

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特征匹配的例子:

SIFT算法的教程、源码及应用软件

1、ubc:DAVID LOWE---SIFT算法的创始人,两篇巨经典经典的文章
http://www.cs.ubc.ca/~lowe/

2、cmu:YanKe---PCASIFT,总结的SIFT方面的文章SO全,巨经典
http://www.andrew.cmu.edu/user/yke/

3、ubc:MBROWN---SIFT算法用于图像拼接的经典应用autopano-sift,包括一个SIFTLIB库
http://www.cs.ubc.ca/~mbrown/autostitch/autostitch.html
http://www.cs.ubc.ca/~mbrown/panorama/panorama.html

4、toronto:Jepson---Matlab SIFT tutorial, 超级超级超级经典~
http://www.cs.toronto.edu/~jepson

5、ucla:Vedaldi---加州大学一个博士生编的SIFT,Matlab、C的都有,但没用过
http://www.cs.ucla.edu/~vedaldi/

6、一个小的拼接软件ptasmblr
http://www.tawbaware.com/ptasmblr.htm

作为一种匹配能力较强的局部描述算子,SIFT算法的实现相当复杂,但从软件开发的角度来说,只要会使用其中几个比较重要的函数就行了。这里要感谢David Lowe这个大牛,不但提供了一种强悍的特征匹配算法,还给出了C++的实现代码,后来有人用C#实现了这个算法,需要的朋友可到网上自行下载。

关键函数一:   int sift_features( IplImage* img, struct feature** feat )

这个函数就是用来提取图像中的特征向量。参数img为一个指向IplImage数据类型的指针,用来表示需要进行特征提取的图像。IplImage是opencv库定义的图像基本类型(关于opencv是一个著名的图像处理类库,详细的介绍可以参见http://www.opencv.org.cn)。参数feat 是一个数组指针,用来存储图像的特征向量。函数调用成功将返回特征向量的数目,否则返回-1.

关键函数二:

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 )

这个函数是函数一的重载,作用是一样的,实际上函数一只不过是使用默认参数调用了函数二,核心的代码都是在函数二中实现的。下面将详细介绍一下其他的几个参数。

intvls: 每个尺度空间的采样间隔数,默认值为3.

sigma: 高斯平滑的数量,默认值1.6.

contr_thr:判定特征点是否稳定,取值(0,1),默认为0.04,这个值越大,被剔除的特征点就越多。

curv_thr:判定特征点是否边缘点,默认为6.

img_dbl:在建立尺度空间前如果图像被放大了1倍则取值为1,否则为0.

descr_width:计算特征描述符时邻域子块的宽度,默认为4.

descr_hist_bins:计算特征描述符时将特征点邻域进行投影的方向数,默认为8,分别是0,45,90,135,180,215,270,315共8个方向。

如果只是做特征提取,上面这个函数就足够了,不同图像之间的匹配都是建立在这个基础上的,如果你有足够强的编程能力即使不懂这个算法也能够编写出像样的程序来,因为下面的比较说白了都是数据结构的比较,跟算法已经没有太多关系了。如果想要深入了解算法,还是认真的看论文和代码吧。

============================================

SIFT: Scale Invariant Feature Transform

SIFT: Scale Invariant Feature Transform

by Utkarsh in Computer Vision,Featured

Matching features across different images in a common problem in computer vision. When all images are similar in nature (same scale, orientation, etc) simple corner detectors can work. But when you have images of different scales and rotations, you need to use the Scale Invariant Feature Transform.

Why care about SIFT

SIFT isn’t just scale invariant. You can change the following, and still get good results:

  • Scale (duh)
  • Rotation
  • Illumination
  • Viewpoint

Here’s an example. We’re looking for these:

And we want to find these objects in this scene:

Here’s the result:

Now that’s some real robust image matching going on. The big rectangles mark matched images. The smaller squares are for individual features in those regions. Note how the big rectangles are skewed. They follow the orientation and perspective of the object in the scene.

The algorithm

SIFT is quite an involved algorithm. It has a lot going on and can become confusing, So I’ve split up the entire algorithm into multiple parts. Here’s an outline of what happens in SIFT.

  1. Constructing a scale space
    This is the initial preparation. You create internal representations of the original image to ensure scale invariance. This is done by generating a “scale space”.
  2. LoG Approximation
    The Laplacian of Gaussian is great for finding interesting points (or key points) in an image. But it’s computationally expensive. So we cheat and approximate it using the representation created earlier.
  3. Finding keypoints
    With the super fast approximation, we now try to find key points. These are maxima and minima in the Difference of Gaussian image we calculate in step 2
  4. Get rid of bad key points
    Edges and low contrast regions are bad keypoints. Eliminating these makes the algorithm efficient and robust. A technique similar to the Harris Corner Detector is used here.
  5. Assigning an orientation to the keypoints
    An orientation is calculated for each key point. Any further calculations are done relative to this orientation. This effectively cancels out the effect of orientation, making it rotation invariant.
  6. Generate SIFT features
    Finally, with scale and rotation invariance in place, one more representation is generated. This helps uniquely identify features. Lets say you have 50,000 features. With this representation, you can easily identify the feature you’re looking for (say, a particular eye, or a sign board).

That was an overview of the entire algorithm. Over the next few days, I’ll go through each step in detail. Finally, I’ll show you how to implement SIFT in OpenCV!

SIFT算法一点小资料:目前有6 条留言

  1. guobo : 2011年10月04日1:36 下午 回复

    找了几天找到相关的东西 还是请教一下博主

    一个扫描文档,图片格式,全部英文。想把一个个的字符分割出来,便于统计像素啊,统计什么的,不晓得怎么去做,希望楼主给点思路,或者有什么相关源码的最好了~

    • 丕子 : 2011年10月04日2:00 下午 回复

      OCR的东西?

  2. guobo : 2011年10月04日2:16 下午 回复

    不是OCR,就是想把字符分割出来~

  3. guobo : 2011年10月04日2:18 下午 回复

    基于像素 或者连同区域 来分割 , 没有思路啊~ 一团糟~

  4. guobo : 2011年10月04日2:44 下午 回复

    二值化: 就是变成黑白图
    去噪:通过膨胀收缩等二值算法,取掉噪声点
    分离: 将方块的汉字分离出来
    正规化: 将分离出来的文字图像大小正规化,就是都改为统一的大小
    细线化:保持文字的笔画结构不变,将线宽都变成一个像素,这一步较困难,不过有现成的算法可以参考,也可以自己针对具体情况提出新的算法
    寻找关键点:细线化之后,就可以寻找 三叉点、四叉点、拐点等特殊的点信息了
    分段:这些关键点将文字分为很多小线段
    比对:将关键点和分段信息和数据库中的标准字的数据进行比较,寻找最接近的文字。每个文字需要按照字体保存多个模板,因为字体不一样,分段和关键点的信
    息都不同。

    我这里还不需要中文 貌似中文还难 我就是要英文
    也就是想做 分离: 将方块的汉字分离出来
    把英文字符分离出来

    • 丕子 : 2011年10月04日2:55 下午 回复

      英文字母分离还好点儿,循环找断电。汉字的话因为有左右结构,就得费一番功夫了。我也没啥好办法 去social的地方问问呗 weibo啥的

给我留言


/ 快捷键:Ctrl+Enter

无觅相关文章插件,快速提升流量

不想听你唠叨×