⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 harris.m

📁 这是<<Matlab在图像处理中的应用>>这本书的源码
💻 M
字号:
%程序13-1
function [cornerness, r, c] = harris(im, sigma, thresh, radius, disp)
% cornerness = Corner values
% r = rows (x coordinate of feature point)
% c = columns (y coordinate of feature points)
im=double(im);    
% Derivative masks
dy = [-1 0 1; -1 0 1; -1 0 1];
dx = dy'; %dx is the transpose matrix of dy
% Ix and Iy are the horizontal and vertical edges of image
Ix = double(conv2(im, dx, 'same')); 
Iy = conv2(im, dy, 'same'); 
% Calculating the gradient of the image Ix and Iy
g = fspecial('gaussian',max(1,fix(6*sigma)), sigma);
Ix2 = conv2(Ix.^2, g, 'same'); % Smoothed squared image derivatives
Iy2 = conv2(Iy.^2, g, 'same');
Ixy = conv2(Ix.*Iy, g, 'same');
cornerness = (Ix2.*Iy2 - Ixy.^2)./(Ix2 + Iy2 + eps); 
% We should perform nonmaximal suppression and threshold
if nargin > 2 
    sze = 2*radius+1;                                  % Size of mask
mx = ordfilt2(cornerness,sze^2,ones(sze));         % Grey-scale dilate
cornerness = (cornerness==mx)&(cornerness>thresh); % Find maxima
[r,c] = find(cornerness);                          % Find row,col coords.
else
    r = []; c = [];
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -