📄 ihough.m
字号:
%IHOUGH Hough transform%% [H TH D] = IHOUGH(IM)% [H TH D] = IHOUGH(IM, Nd)% [H TH D] = IHOUGH(IM, Nd, Nth)%% Compute the Hough transform of the image IM data. Only non-zero pixels% increment the accumulator and the increment is the absolute value of % the pixel value.%% The accumulator array has theta across the columns and offset down % the rows. Theta spans the range -pi/2 to pi/2 in Nth increments.% Offset is in the range 1 to number of rows of IM with Nd steps.% Both Nth and Nd default to 64.%% Clipping is applied so that only those points lying within the Hough % accumulator bounds are updated.%% The output arguments TH and D give the theta and offset value vectors % for the accumulator columns and rows respectively. With no output % arguments the Hough accumulator is displayed as a greyscale image.% % For this version of the Hough transform lines are described by%% d = y cos(theta) + x sin(theta)%% where theta is the angle the line makes to horizontal axis, and d is % the perpendicular distance between (0,0) and the line. A horizontal % line has theta = 0, a vertical line has theta = pi/2 or -pi/2%% SEE ALSO: xyhough mkline, mksq, isobel ilap%% Copyright (c) Peter Corke, 1999 Machine Vision Toolbox for Matlab% 1995 Peter Corkefunction [H,TH,D] = ihough(IM, Nd, Nth) nc = numcols(IM); nr = numrows(IM); if nargin < 3, Nth = 64; end if nargin < 2, Nd = 64; end IM = abs(IM); i = find(IM > 0) - 1; % find the indices of each non-zero pixel x = floor(i/nr)+1; % determine (x,y) coordinate y = rem(i, nr)+1; xyz = [x y IM(i+1)]; switch nargout, case 0, xyhough(xyz, [1 nr Nd], Nth); case 1, H = xyhough(xyz, [1 nr Nd], Nth); case 2, [H,TH] = xyhough(xyz, [1 nr Nd], Nth); case 3, [H,TH,D] = xyhough(xyz, [1 nr Nd], Nth); end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -