📄 findline.m
字号:
% findline - returns the coordinates of a line in an image using the
% linear Hough transform and Canny edge detection to create
% the edge map.
%
% Usage:
% lines = findline(image)
%
% Arguments:
% image - the input image
%
% Output:
% lines - parameters of the detected line in polar form
%
% Author:
% Libor Masek
% masekl01@csse.uwa.edu.au
% School of Computer Science & Software Engineering
% The University of Western Australia
% November 2003
function lines = findline(image)
[I2 or] = canny(image, 2, 1, 0.00, 1.00);
I3 = adjgamma(I2, 1.9);
I4 = nonmaxsup(I3, or, 1.5);
edgeimage = hysthresh(I4, 0.20, 0.15);
theta = (0:179)';
[R, xp] = radon(edgeimage, theta);
maxv = max(max(R));
if maxv > 25
i = find(R == max(max(R)));
else
lines = [];
return;
end
[foo, ind] = sort(-R(i));
u = size(i,1);
k = i(ind(1:u));
[y,x]=ind2sub(size(R),k);
t = -theta(x)*pi/180;
r = xp(y);
lines = [cos(t) sin(t) -r];
cx = size(image,2)/2-1;
cy = size(image,1)/2-1;
lines(:,3) = lines(:,3) - lines(:,1)*cx - lines(:,2)*cy;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -