点检测matlab代码,Harris角点检测matlab代码

Harris角点检测代码

%%%Prewitt Operator Corner Detection.m

%%%时间优化--相邻像素用取差的方法

%%

clear;

for nfigure=1:6

t=input('input your figure’s name(including its extern name):','s');

% t1 = tic; %测算时间

FileInfo = imfinfo(t); % 保存图像的所有信息

Image = imread(t); % 读取图像

% 转为灰度值图像(Intensity Image)

if(strcmp('truecolor',FileInfo.ColorType) == 1) %转为灰度值图像

Image = im2uint8(rgb2gray(Image));

end

dx = [-1 0 1;-1 0 1;-1 0 1]; %dx:横向Prewitt差分模版

Ix2 = filter2(dx,Image).^2;

Iy2 = filter2(dx',Image).^2;

Ixy = filter2(dx,Image).*filter2(dx',Image);

%生成9*9高斯窗口。窗口越大,探测到的角点越少。

h= fspecial('gaussian',9,2);

A = filter2(h,Ix2); % 用高斯窗口差分Ix2得到A

B = filter2(h,Iy2);

C = filter2(h,Ixy);

nrow = size(Image,1);

ncol = size(Image,2);

Corner = zeros(nrow,ncol); %矩阵Corner用来保存候选角点位置,初值全零,值为1的点是角点

%真正的角点在137和138行由(row_ave,column_ave)得到

%参数t:点(i,j)八邻域的“相似度”参数,只有中心点与邻域其他八个点的像素值之差在

%(-t,+t)之间,才确认它们为相似点,相似点不在候选角点之列

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值