matlab实现hough变换检测直线

matlab实现hough变换检测直线,提示错误FunctionHOUGHexpecteditssecondinput,PARAM,tobeoneofthesetypes... matlab实现hough变换检测直线,提示错误Function HOUGH expected its second input, PARAM,
to be one of these types:har Instead its type was double.具体代码如下:
clear all;
clc;
f = imread('C:\Users\lenovo\Desktop\canny.jpg');
figure
imshow(f, []);
[H, theta, rho] = hough(f, 0.5);
figure
imshow(H, [],'Xdata', theta, 'Ydata', rho, 'InitialMagnification','fit');
axis on, axis normal

[r, c] = houghpeaks(H, 5);
hold on;
plot(theta(c), rho(r), 'linestyle', 'none', 'marker', 's', 'color', 'w')

lines = houghlines(f, theta, rho, r, c)
figure, imshow(f, []), hold on
for k = 1: length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:, 2), xy(:, 1), 'LineWidth', 4, 'Color', [.6, .6, .6]);
end
错误提示具体如下:
Warning: Image is too big to fit on screen; displaying at 67%
> In imuitools\private\initSize at 73
In imshow at 262
In kljh at 3
??? Error using ==> iptcheckinput
Function HOUGH expected its second input, PARAM,
to be one of these types:

char

Instead its type was double.

Error in ==> iptcheckstrs at 43
iptcheckinput(in, {'char'}, {'row'}, function_name, variable_name, ...

Error in ==> hough>parseInputs at 126
inputStr = iptcheckstrs(input, validStrings,mfilename,'PARAM',idx);

Error in ==> hough at 93
[bw, rho, theta] = parseInputs(varargin{:});

Error in ==> kljh at 4
[H, theta, rho] = hough(f, 0.5);
求大神讲解。
我附带的图已经经过灰度化,滤波,二值分割,canny边缘检测。
展开
 我来答
我行我素850915
2014-05-21 · TA获得超过8241个赞
知道大有可为答主
回答量:5788
采纳率:77%
帮助的人:1753万
展开全部
clear all;
clc;
r = imread('C:\Users\lenovo\Desktop\canny.jpg');
t=rgb2gray(r);
figure,imshow(t)
f=edge(t,'canny');
figure,imshow(f)
[H, theta, rho] = hough(f,'RhoResolution',0.5,'Theta',-90:0.5:89.5);
figure
imshow(imadjust(H),'Xdata', theta, 'Ydata', rho, 'InitialMagnification','fit');
axis on, axis normal
p= houghpeaks(H, 5);
%[r,c] = houghpeaks(H, 5);
hold on;
%plot(theta(r), rho(c), 'linestyle', 'none', 'marker', 's', 'color', 'w')
plot(p, 'linestyle', 'none', 'marker', 's', 'color', 'r')
lines = houghlines(f, theta, rho,p);
%lines = houghlines(f, theta, rho, r, c);
figure,
imshow(t)
hold on
for k = 1: length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:, 2), xy(:, 1), 'LineWidth', 4, 'Color', [.6, .2, .1]);
end
hold off

按上面语句试试
更多追问追答
追问
不行,还有我的图已经灰度,滤波,二值分割,边缘检测过了。运行后出现
Error using ==> rgb2gray>parse_inputs at 82
MAP must be a m x 3 array.
Error in ==> rgb2gray at 35
X = parse_inputs(varargin{:});
Error in ==> shiyan1 at 4
t=rgb2gray(r);
追答
如果你的图已经是灰度图了,就用%把t=rgb2gray(r);注释掉
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式