优化的Harris角点检测算法的MATLAB实现

%%%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(Im

你可能感兴趣的:(Matlab)