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

📄 harris角点提取.txt

📁 harris交点提取matlab实现
💻 TXT
字号:
1.【求助】matlab中的harris角点提取的问题  Copy to clipboard 
Posted by: mog
Posted on: 2005-11-16 15:23

我前几天从网上找了一个角点提取的源码,但是执行的时候老是出现这样的问题:

??? Error using ==> conv2
A and B must be full double matrices.

Error in ==> D:\MATLAB\work\harris.m
On line 51 ==> Ix = conv2(im, dx, 'same'); % Image derivatives

我现在附上源程序,请大家帮忙看看:

% HARRIS - Harris corner detector
%
% Usage: [cim, r, c] = harris(im, sigma, thresh, radius, disp)
%
% Arguments: 
% im - image to be processed.
% sigma - standard deviation of smoothing Gaussian. Typical
% values to use might be 1-3.
% thresh - threshold (optional). Try a value ~1000.
% radius - radius of region considered in non-maximal
% suppression (optional). Typical values to use might
% be 1-3.
% disp - optional flag (0 or 1) indicating whether you want
% to display corners overlayed on the original
% image. This can be useful for parameter tuning.
%
% Returns:
% cim - binary image marking corners.
% r - row coordinates of corner points.
% c - column coordinates of corner points.
%
% If thresh and radius are omitted from the argument list 'cim' is returned
% as a raw corner strength image and r and c are returned empty.
这部分是参数设置的说明
function [cim, r, c] = harris(im, sigma, thresh, radius, disp)

error(nargchk(2,5,nargin));

dx = [-1 0 1; -1 0 1; -1 0 1]; % Derivative masks
dy = dx';

Ix = conv2(im, dx, 'same'); % Image derivatives
Iy = conv2(im, dy, 'same'); 

% Generate Gaussian filter of size 6*sigma (+/- 3sigma) and of
% minimum size 1x1.
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');

% Compute the Harris corner measure. Note that there are two measures
% that can be calculated. I prefer the first one below as given by
% Nobel in her thesis (reference above). The second one (commented out)
% requires setting a parameter, it is commonly suggested that k=0.04 - I
% find this a bit arbitrary and unsatisfactory. 

cim = (Ix2.*Iy2 - Ixy.^2)./(Ix2 + Iy2 + eps); % My preferred measure.
% k = 0.04;
% cim = (Ix2.*Iy2 - Ixy.^2) - k*(Ix2 + Iy2).^2; % Original Harris measure.

if nargin > 2 % We should perform nonmaximal suppression and threshold

% Extract local maxima by performing a grey scale morphological
% dilation and then finding points in the corner strength image that
% match the dilated image and are also greater than the threshold.
sze = 2*radius+1; % Size of mask.
mx = ordfilt2(cim,sze^2,ones(sze)); % Grey-scale dilate.
cim = (cim==mx)&(cim>thresh); % Find maxima.

[r,c] = find(cim); % Find row,col coords.

if nargin==5 & disp % overlay corners on original image
show(im,1), hold on
plot(c,r,'r+'), title('corners detected');
end

else % leave cim as a corner strength image and make r and c empty.
r = []; c = [];
end

执行程序部分.

注意话题分类  

--------------------------------------------------------------------------------
2.Re:【求助】matlab中的harris角点提取的问题 [Re: mog] Copy to clipboard 
Posted by: talon
Posted on: 2005-11-17 09:32

要将图像im转换成double类型的,不知你转换了没有,我运行了上面的程序,没有出错。  

⌨️ 快捷键说明

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