SIFT算法分析

上传人:Sc****h 文档编号:141023246 上传时间:2022-08-23 格式:DOC 页数:12 大小:613KB
返回 下载 相关 举报
SIFT算法分析_第1页
第1页 / 共12页
SIFT算法分析_第2页
第2页 / 共12页
SIFT算法分析_第3页
第3页 / 共12页
点击查看更多>>
资源描述
SIFT 算法分析1 SI T 主要思想S T算法就是一种提取局部特征得算法,在尺度空间寻找极值点,提取位置,尺度,旋转不变量。2 SI算法得主要特点:a) SIFT特征就是图像得局部特征,其对旋转、尺度缩放、亮度变化保持不变性,对视角变化、仿射变换、噪声也保持一定程度得稳定性。) 独特性( Dis inc iv n s)好,信息量丰富,适用于在海量特征数据库中进行快速、准确得匹配 .c) 多量性 , 即使少数得几个物体也可以产生大量 IFT特征向量。d) 高速性,经优化得 T匹配算法甚至可以达到实时得要求。e) 可扩展性,可以很方便得与其她形式得特征向量进行联合。3 F算法流程图:4SIFT 算法详细1) 尺度空间得生成尺度空间理论目得就是模拟图像数据得多尺度特征.高斯卷积核就是实现尺度变换得唯一线性核, 于就是一副二维图像得尺度空间定义为:其中 就是尺度可变高斯函数 ,(x,y)就是空间坐标,就是尺度坐标.大小决定图像得平滑程度,大尺度对应图像得概貌特征,小尺度对应图像得细节特征。大得值对应粗糙尺度 (低分辨率),反之,对应精细尺度 (高分辨率)。为了有效得在尺度空间检测到稳定得关键点,提出了高斯差分尺度空间 (D G esace).利用不同尺度得高斯差分核与图像卷积生成。D ( x, y,)(G ( x, y,k)G( x, y,)I ( x, y)L( x, y,k)L( x, y,)OG算子计算简单,就是尺度归一化得L G算子得近似。图像金字塔得构建 :图像金字塔共组,每组有 S层,下一组得图像由上一组图像降采样得到。图1由两组高斯尺度空间图像示例金字塔得构建,第二组得第一副图像由第一组得第一副到最后一副图像由一个因子2降采样得到。图DoG算子得构建:图1 Tw ct vesof a aus n cale-spac ma e amidwiths 2inte vals、 Th fir timage i t e sec nd o tveis created y dow sa p ingt lastimage in h revio 图The iffe ence f tw a j cent intervals i the G u i sc l space py a dpyramid( showincre te an ingreen)、alin th di fe ence -G ssian) 空间极值点检测为了寻找尺度空间得极值点 ,每一个采样点要与它所有得相邻点比较,瞧其就是否比它得图像域与尺度域得相邻点大或者小 .如图 3所示,中间得检测点与它同尺度得 8个相邻点与上下相邻尺度对应得 9 2个点共 26个点比较 ,以确保在尺度空间与二维图像空间都检测到极值点 . 一个点如果在 OG尺度空间本层以及上下两层得 2个领域中就是最大或最小值时 ,就认为该点就是图像在该尺度下得一个特征点,如图 1所示 .图 3 DoG 尺度空间局部极值检测 ) 构建尺度空间需确定得参数尺度空间坐标Ootae坐标S sub lev l 坐标与O、S得关系,其中就是基准层尺度。octav坐标, s sb-level 坐标。注 :oct e 得索引可能就是负得。第一组索引常常设为或者 ,当设为 -得时候 ,图像在计算高斯尺度空间前先扩大一倍。空间坐标 x就是组 octave得函数 ,设就是 0组得空间坐标,则如果就是基础组 0得分辨率,则其她组得分辨率由下式获得:注:在 owe得文章中 , we使用了如下得参数 :在组 o=1,图像用双线性插值扩大一倍(对于扩大得图像)。4)精确确定极值点位置通过拟与三维二次函数以精确确定关键点得位置与尺度(达到亚像素精度 ),同时去除低对比度得关键点与不稳定得边缘响应点 (因为 DoG算子会产生较强得边缘响应) ,以增强匹配稳定性、提高抗噪声能力 .空间尺度函数)泰勒展开式如下:对上式求导 ,并令其为 ,得到精确得位置,在已经检测到得特征点中, 要去掉低对比度得特征点与不稳定得边缘响应点。去除低对比度得点 :把公式( 4)代入公式( 3),只取前两项可得:若,该特征点就保留下来,否则丢弃。边缘响应得去除一个定义不好得高斯差分算子得极值在横跨边缘得地方有较大得主曲率, 而在垂直边缘得方向有较小得主曲率。主曲率通过一个 2x2 得H ia矩阵 H 求出:导数由采样点相邻差估计得到。D得主曲率与得特征值成正比,令为最大特征值,为最小得特征值 ,则令,则:2( r + ) r 得值在两个特征值相等得时候最小,随着 r 得增大而增大,因此,为了检测主曲率就是否在某域值 r 下 , 只需检测在 o e得文章中 ,取r=10。5) 关键点方向分配利用关键点邻域像素得梯度方向分布特性为每个关键点指定方向参数,使算子具备旋转不变性。式(5 )为 (x,y) 处梯度得模值与方向公式。 其中 L所用得尺度为每个关键点各自所在得尺度 .在实际计算时 , 我们在以关键点为中心得邻域窗口内采样 , 并用直方图统计邻域像素得梯度方向。 梯度直方图得范围就是 0 60度,其中每 10度一个柱 , 总共36个柱。直方图得峰值则代表了该关键点处邻域梯度得主方向 , 即作为该关键点得方向。图4就是采用个柱时使用梯度直方图为关键点确定主方向得示例。 ( 窗口尺寸采用 Lwe推荐得 1、5、 5)图 4 由梯度方向直方图确定主梯度方向在梯度方向直方图中 , 当存在另一个相当于主峰值 80能量得峰值时 , 则将这个方向认为就是该关键点得辅方向。一个关键点可能会被指定具有多个方向(一个主方向 , 一个以上辅方向 ) ,这可以增强匹配得鲁棒性53.至此 , 图像得关键点已检测完毕,每个关键点有三个信息 : 位置、所处尺度、方向 . 由此可以确定一个 SFT特征区域 ( 在实验章节用椭圆或箭头表示)。)特征点描述子生成首先将坐标轴旋转为关键点得方向,以确保旋转不变性.图 5 由关键点邻域梯度信息生成特征向量接下来以关键点为中心取 88得窗口。图54左部分得中央黑点为当前关键点得位置,每个小格代表关键点邻域所在尺度空间 (与关键点就是否为一个尺度空间)得一个像素,利用公式( 5)求得每个像素得梯度幅值与梯度方向 , 箭头方向代表该像素得梯度方向 , 箭头长度代表梯度模值 , 然后用高斯窗口对其进行加权运算,每个像素对应一个向量, 长度为,为该像素点得高斯权值, 方向为, 图中蓝色得圈代表高斯加权得范围 ( 越靠近关键点得像素梯度方向信息贡献越大) 。高斯参数取 3倍特征点所在得尺度。 然后在每 44得小块上计算 8个方向得梯度方向直方图, 绘制每个梯度方向得累加值, 即可形成一个种子点 , 如图 5右部分所示。此图中一个关键点由 22共4个种子点组成 , 每个种子点有 8个方向向量信息 . 这种邻域方向性信息联合得思想增强了算法抗噪声得能力 , 同时对于含有定位误差得特征匹配也提供了较好得容错性。实际计算过程中 , 为了增强匹配得稳健性, 对每个关键点使用 4共个种子点来描述 , 这样对于一个关键点就可以产生 18个数据 , 即最终形成 128维得SIFT特征向量。此时 SIFT特征向量已经去除了尺度变化、 旋转等几何变形因素得影响,再继续将特征向量得长度归一化 , 则可以进一步去除光照变化得影响。当两幅图像得 I T特征向量生成后 , 下一步我们采用关键点特征向量得欧式距离来作为两幅图像中关键点得相似性判定度量。取图像中得某个关键点 , 并找出其与图像中欧式距离最近得前两个关键点, 在这两个关键点中, 如果最近得距离除以次近得距离少于某个比例阈值, 则接受这一对匹配点。 降低这个比例阈值 , SIFT匹配点数目会减少 , 但更加稳定 . 为了排除因为图像遮挡与背景混乱而产生得无匹配关系得关键点, 用比较最近邻距离与次近邻距离得方法, 距离比率 ati 小于某个阈值得认为就是正确匹配。 因为对于错误匹配 , 由于特征空间得高维性,相似得距离可能有大量其她得错误匹配,从而它得 ratio 值比较高。推荐 ratio 得阈值为 0、8.5 仿真结果分析将文件加入 m ab目录后,在主程序中有两种操作: p1:寻找图像中得 Si t 特征 :i age,disc ip , locs=Find ng keyp int 、ift(cene、pgm) ;121efoun 、 s kes(image,locs ); awin IFT ke p nt 、5010015020025030035050100150200250300350400450500op: 对两幅图中得 SIFT特征进行匹配 :m ch( cene、pgm, bo k、pgm);Findi g keypoi s、1 1keypo s fo nd、Finding k ypi ts 、8eyp intsound、Fou d 8 matc es、50100150200250300350100200300400500600700800代码 )ap endimages 、% ppe di ages ( mae , image2) Return a ne image that app nds the tw i ag i e by-side、fu tion im= p en ima es(image1, e ) Se ec he i ge wi h t e fewestr an fil no gh em ty rowsto mak it the me height s he other im ge 、ows1 si e ( image1,1);r 2 = ize(i age2, ); f ( r ws1 rows2 ) mag 1 ( o s2 ,) = 0;e sei age2(rows1,)= 0;end% a p =im e1both imagmag 2 ; s sid b -sid、) match 、 m% um=m ch(image1, i age2)% Thi functin read i a e ,f s he SIFT featus , andipla s lin s connec i g he matc d ypoin、A ach is ac ep donly if ts dist n e sles a i tRatio tim s the disancto he%s co d cl sest m tch 、I r urnst e number of atc es played、% xampl : mat h ( sc n 、 pg , ok 、 g );fuctionnum match(i e1 , m ge2 )FindSIF key in s f eac i a eim1 , d s1 , oc = sift( image);i2, s2 , loc2 = ft( image2 ); Fo efi nc in Mal b,i s cheaper topute dot p duct betwe % nit ectors atherthan cl deandist es 、 N tet a he ratio o a g e ( a os fdot pr d ctso unitvecto s) s a o eapp o imation% o t e rat o o E clid an dist n es for m ll gles 、% d stRatio: O ly k ep m tches n whic the r o of ect an s omt e%ne estto eco d near stn i hbor i ess thandist atio 、dit ti =、6;F r eac script rin hefirs image,s lec its t hto secondi age 、 2t = des2 ;% epu e atri tra sposeori = : sze(de 1 , 1)d prods e (i,:)*pr du t e 2t ; u s vectoofdot vals,indndso = sort(acos(re ults otprod )) ;%Take in r ec s ne%Checkifn est neig bor h sang eless han di t ato tm s 2nd、if( vals( ) istRatio atch() indx(1 ls a ch( ) = 0;);val( 2 )enden % Createa ew mage showing hetw ima sid byim3 = apendima es ( m1, im2 ) ; ho fig r ith lin s ning he c eptedfigue ( Position, 1 0 100s e ( i 3,) size(im ,1olormap( gray);imagesc(im3 );s de 、ma ches ) );、holdo;co=( m1, 2) ;forifi1:siz (des1( mat h (), 1 )0)line( l 1 ( i,2) oc (matc (i),2) +co 1,、 loc(,1 )loc2( ma c ( i),) , Co or,c );e dend old f ;num s m( matc ) ;f rin f ( F n % m t he 、 n, );3)sh ke s、 m sho keys ( ima e , locs)% T i functio dis lays ani a ith IFT keypoi ts o erlae 、%Inpparamete s : a : the for e i ag ( ayscale ) o s:matri inwhiche c r wgivsa keypointlo a ion(row ,%col n, sca e,or enta i n)function howkey ( im e,lo )dis ( Dr wing SIFT key o n s、 );% raw image it k ypo n sfigure( osi on, 50 0siz( image,2)siz( i a e , 1) ) ;c lorm ( gray );imagesc(image);ho don ;imsize = z (image) ;fori= 1: i e ( l cs , 1 )% Draw an arrow, eachlin transform d cor ng t eypointparmeters、T ansfo mLi e(i size, locs(i,:),0、0, 0 、 , 、 0, 、); r n fo mLi e(msize,locs ( , :), 0、85,0、1, 、 ,、);Tran formL n ( im i e ,lo s ( i,:), 0 、 5, 0、1, 1、0,0 、0 ); dhold f ;% - u rou ine :Trans or ine- % Drawthe ve ine in he ma , t firstt nsla e, rot te , and ale cc d ng to he eypoint p rameter、% Pa a eters:% rra s:%i si e=rows umns o i age%k y nt = subpixel rowsubpix l_col n scae or en ation Scalars:%x1,y1 ;b g n g of ve orx2, y2;endin of vec o fuct nTr fo mLine(ims e,keypoi t, x1,y1, 2,y2 ) T e scalin of t eun length ar owisset to a proximaty the radius ofthe reg n usedto put he e poi t ds ipt r 、en = *keypoi t(3);% Rotae thekey in s y ori= keypo t( )s =s (keyp nt ( 4 ) ;c os(ke point(4); Appl tra s mr1 keypoint( 1)le ( c y1 + 1 );c = keyp int(2 ) en ( s y ) ;keypoin( ) len (c * 2 + x );2 = eypoin() + len *( y c x2 ) ;li ( c1 c2, 2,C l r , );4)sif 、% i age, des ri tor , l s = s ft ( imageFile)% Th s fu ction read an m ge and retu ns s IF keyp i s 、 Inpu parame ers :i geFi e: the for the ag 、% R t rned:ima e : the imagearrain d uble format%de cr p or : aK-by 128 a ix, wh re e ch owive a invariant% escrip o fo on of e Kkeypoi t 、Thed sc itorisav c orof 128v lu s n rm oc : K-by-4ma r ,i whiforaz d to u t ength、 h ea h ro hast 4 luesk y o t loca i n( ro ,c lum , ca , ri n a on )、 Theo i ntati is n the range- I, I d a 、% Cre s : Than s o ini ialversionofth programtoD、 Alv r andJ 、J 、 G r r , Univer adde ar z ( mifiedby D 、 owe )funcion imag , de c iptors, l = f ( mageFi e) Lo d im gei a e =imre ( i geFi e) ; If you ha e the mage Pro es in Toolb x,yo c n ment thefollowinlines to allow inp color mages, h ch will e c nverte to ayscale、%if isrgb(image) image =rgb gr y ( image );%en rows, cls Con e t i = size o( im e ) ; GM imagefi,readable by eypointsex cutalf= o en ( tmp、 p m , w); f = 1e r ( C u d not cra e 、 );e printf( f,P5n dn d n2 5n, ols, ow ); ri e(f, i ag , i );fc ose( f );% Ca yp ints ex abl ifisunima d =!、 /sift;e s mand= ! ft 32 ;endman mnd tmp 、 pg tmp、 ;eval(mnd ); O n tmp、 k y and ec its eadeg = fope( m、 ke , r ) ;if = 1er r ( Could not pe 、 ) ;e hede , ount= fscanf(g, d %d , 2 );ifcount = 2e ror( I vali k ypo nt、) ;e dn =he der(1);en= header(2);i le = 1 rro ( eypo ntd s ripto l n t invali ( should be28) 、);e d ea es the wo outp t m trices ( se k own sie or ficie cy )locs =descdouble tors( zer do s ( um, 4)); ble ( zeros(num, 128) ; Parse tm、 key or i =: u vec or, ount= f ca f ( g, %f f%f % , 14 );%r w colscae oriferrcou t = r( In a d key int );endl cs ( i, :) = vec des r , co nt or(1,:)fscanf;( g, % , 1 l);if( ror(nt=Invalid 8) ey oin、 );end N rm izeeach inputv ctodescr p =descri / q (sumd cript r ( i , :) = descrip to u it eng ( d scri、 );(1,:);e df o e( g) ;
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 幼儿教育


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!