资源描述:
《harris角点检测与ncc匹配(harris point detection and ncc match)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、harris角点检测与ncc匹配(HarrispointdetectionandNCCmatch)harris角点检测与ncc匹配(HarrispointdetectionandNCCmatch)HarriscornerdetectionandNCCmatchingFile1:--------------------------------------------------------------------------------------Function,[y1,Y2,R,c]=harris(X)%cornerd
2、etectionusingtheHarrisalgorithm%outputisanimage%[result,CNT,R,c]=harris(X)%CLC,clearall;%filename='qiao1.bmp';%X=imread('filename.bmp');%readstheimage%Info=imfinfo(filename);%;thisiscustomary%f=rgb2gray(X);F=X;%Ori_im=double(f)/255;%unit8isconvertedto64doubleprec
3、isiondouble64FX=[-2,-101,2],%Xdirectiongradientoperator(forHarriscornerextractionalgorithm)Ix=Filter2(FX,ori_im);%xdirectionalfilteringisgoodatusingfilter%FY=[585;000;-5,-8,-5];%Gaussfunction,firstorderdifferential,Ydirection(forimprovedHarriscornerextractionalgo
4、rithm)FY=[-2;-1;0;1;2];%Ydirectiongradientoperator(usedinHarriscornerextractionalgorithm)Iy=Filter2(FY,ori_im);%ydirectionalfilteringIx2=Ix.^2;Iy2=Iy.^2;Ixy=Ix.*Iy;ClearIx;ClearIy=%eliminationvariablehaH=,fspecial('gaussian',[10,10],2);%producesGausswindowfunctio
5、nsof7*7,sigma=2Ix2=Filter2(h,Ix2);Iy2=Filter2(h,Iy2);Ixy=Filter2(h,Ixy);%Gaussfiltering,respectivelyHeight=size(ori_im,1);Width=size(ori_im,2);Result=zeros(height,width);%recordcornerposition,cornervalueis1,backgroundisblackhaR=zeros(height,width);Rmax=0;%themaxi
6、mumRvalueintheimageinordertosetthethresholdForI=1:heightForJ=1:widthM=[Ix2(I,J),Ixy(I,J);Ixy(I,J),Iy2(I,J)];%2*2matrixR(I,J)=det(M)-0.06*(trace(M))^2;%calculatesRandobtainsRMAX,whichappearstobethewhole,andthecornerresponsefunctionIfR(I,J)>RmaxRmax=R(I,J);End;End;
7、End;CNT=0;%recordcountForI=2:height-1ForJ=2:width-1%carryonnonmaximumsuppression,window3*3IfR(I,J)>0.01*Rmax&&R(I,J)>R(i-1,J-1)andR(I,J)>R(i-1,J)andR(I,J)>R(i-1,j+1)andR(I,J)(I,J-1>R)andR(I,J)>R(I,j+1)andR(I,J)>R(i+1,J-1)andR(I,J)>R(I+1J)andR(I,J)>R(i+1,j+1)Resul
8、t(I,J)=1;CNT=cnt+1;End;End;End;%%i=1;%forj=1:height%fork=1:width%ifresult(J,K)==1;%corners1(I,1)=j;%corners1(I,2)=k;%i=i+1;%end;%end;%end;[posr,posc]=find(resu