标题:
MATLAB程序 Harris角点检测算法
[打印本页]
作者:
51hei小小
时间:
2017-6-3 01:45
标题:
MATLAB程序 Harris角点检测算法
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%特征点的匹配,主要应用 harris 角点的检测,match单向匹配 函数
%适合于有白边的图像,因为,在加窗滤波的时候,没有限定范围的哈,尽量保证角点不在边上
clc,clear all;
filename1 = '..\.\photo9\cal1-L.txt';
filename2 = '..\.\photo9\cal1-R.txt';
b1 = imread('..\.\photo9\cal1-L.bmp');
b2 = imread('..\.\photo9\cal1-R.bmp'); %double的作用很大的啊
a1 = imadjust(b1);
a2 = imadjust(b2);
%subplot(1,2,1);
%imshow(a1);
%subplot(1,2,2);
%imshow(a2);
%title('原来的图像');
[result1,cnt1,c1,r1]=harris(a1);%角点检测,得到原始的焦点位置图result
[result2,cnt2,c2,r2]=harris(a2);
figure;
subplot(1,2,1);
imshow(a1);
hold on;
plot(r1,c1,'g.');
subplot(1,2,2);
imshow(a2);
hold on;
plot(r2,c2,'g.');
title('图1,2的角点图');
l=[r1 c1];
r=[r2 c2];
fid1=fopen(filename1,'wt');
for i=1:cnt1
for j=1:2
if j==2
fprintf(fid1,'%g\n',l(i,j));
else
fprintf(fid1,'%g\t',l(i,j));
end
end
end
fclose(fid1);
fid2=fopen(filename2,'wt');
for i=1:cnt2
for j=1:2
if j==2
fprintf(fid2,'%g\n',r(i,j));
else
fprintf(fid2,'%g\t',r(i,j));
end
end
end
fclose(fid2);
%res2=match(a1,cnt1,r1,c1,a2,cnt2,r2,c2);%从result1中开始搜索在result2中可能达到的
%[r22,c22]=find(res2==1);
%[m22,n22]=size(r22);
%cnt22=m22;
%res1=match(a2,cnt22,r22,c22,a1,cnt1,r1,c1);%反向搜索res2--result1
%res1=and(res1,result1); %保证反向匹配不会出现不可能的点
%[r11,c11]=find(res1==1);
%[m11,n11]=size(r11);
%cnt11=m11;
%res22=match(a1,cnt11,r11,c11,a2,cnt22,r22,c22);%从res1中开始搜索在res2中可能达到的
……………………
…………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
完整版本下载:
http://www.51hei.com/bbs/dpj-86571-1.html
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1