matlab直线检测代码报错clc;clear;i=imread('test3.jpg'); imshow(i)figurei=rgb2gray(i);i_hight=size(i,1); i_width=size(i,2);i_edge=edge(i,'robert'); i_hough=zeros(360,480);for y=1:i_hightfor x=1:i_widthif i(y,x)==0 %坐标系转换for l=1:360r=x

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 12:09:02

matlab直线检测代码报错clc;clear;i=imread('test3.jpg'); imshow(i)figurei=rgb2gray(i);i_hight=size(i,1); i_width=size(i,2);i_edge=edge(i,'robert'); i_hough=zeros(360,480);for y=1:i_hightfor x=1:i_widthif i(y,x)==0 %坐标系转换for l=1:360r=x
matlab直线检测代码报错
clc;
clear;
i=imread('test3.jpg');
imshow(i)
figure
i=rgb2gray(i);
i_hight=size(i,1);
i_width=size(i,2);
i_edge=edge(i,'robert');
i_hough=zeros(360,480);
for y=1:i_hight
for x=1:i_width
if i(y,x)==0 %坐标系转换
for l=1:360
r=x*cos(l*pi/180)+y*sin(l*pi/180);
w=fix(r)+300; %修正为正整数
%i_hough(w,l)=i_hough(w,l)+1;
end
end
end
end
m=max(max(i_hough));
i_hough=(i_hough./m); %亮度调整
threshold=0.75; %设置直线亮度阈值
ih_hight=size(i_hough,1);
ih_width=size(i_hough,2);
temp=zeros(20,20);
count=0;
for y=1:ih_hight %找那些亮度高的直线
for x=1:ih_width/2
if i_hough(y,x)>threshold
count = count+1;
temp(count,1) = x;
temp(count,2) = y;
end
end
end
imshow(i)
hold on
for i=1:count %画
y=kx+b
k = tan(temp(i,1)*pi/180);
b = (temp(i,2)-300)/sin(temp(i,1)*pi/180);
for j=1:360
x(j)=j;
y(j)=-x(j)/k+b;
end
plot(x,y)
hold on
end
axis equal
figure
imshow(i_hough)
高亮度的直线没有检测,那个大哥修改一下啊

matlab直线检测代码报错clc;clear;i=imread('test3.jpg'); imshow(i)figurei=rgb2gray(i);i_hight=size(i,1); i_width=size(i,2);i_edge=edge(i,'robert'); i_hough=zeros(360,480);for y=1:i_hightfor x=1:i_widthif i(y,x)==0 %坐标系转换for l=1:360r=x
你用我的代码试试
hough变换的直线检测
close all;
clear all;
clc;
%%
I = imread('8_traffic.bmp','bmp');
BW = edge(I,'sobel');
[H,T,R] = hough(BW);
imshow(H,[],'XData',T,'YData',R,...
'InitialMagnification','fit');
xlabel('\theta'),ylabel('\rho');
axis on,axis normal,hold on;
P = houghpeaks(H,10,'threshold',ceil(0.3*max(H(:))));
x = T(P(:,2)); y = R(P(:,1));
figure(1);
plot(x,y,'s','color','white');
% Find lines and plot them
lines = houghlines(BW,T,R,P,'FillGap',20,'MinLength',40);
figure(2);
[g,t]=edge(I,'sobel',[],'both');
imshow(I);
hold on;
% imshow(g);
max_len = 0;
for k = 1:length(lines)
xy = [lines(k).point1; lines(k).point2];
plot(xy(:,1),xy(:,2),'LineWidth',2,'Color','green');
% Plot beginnings and ends of lines
plot(xy(1,1),xy(1,2),'x','LineWidth',2,'Color','yellow');
plot(xy(2,1),xy(2,2),'x','LineWidth',2,'Color','red');
% Determine the endpoints of the longest line segment
len = norm(lines(k).point1 - lines(k).point2);
if ( len > max_len)
max_len = len;
xy_long = xy;
end
end
% highlight the longest line segment
plot(xy_long(:,1),xy_long(:,2),'LineWidth',2,'Color','cyan');

matlab直线检测代码报错clc;clear;i=imread('test3.jpg'); imshow(i)figurei=rgb2gray(i);i_hight=size(i,1); i_width=size(i,2);i_edge=edge(i,'robert'); i_hough=zeros(360,480);for y=1:i_hightfor x=1:i_widthif i(y,x)==0 %坐标系转换for l=1:360r=x matlab画图报错、、、、clc,clearx=-10:0.1:10;y=x.*(x4);plot(x,y) MATLAB中clc是什么意思 matlab 中 clc 与 clear的差别 Matlab命令,.clc表示:;more表示:; 我用matlab做神经网络,报错“Error using horzcat.CAT arguments dimensions are not consistent.以下是我的代码和workspace~ Matlab程序问题(高分求解决)Attempted to access speak1(12001); index out of bounds because numel(speak1)=12000.这是matlab的报错,下面是程序%AAWclear;close all;clc;M=10 Q=16 N=80; p=1500; speak1=wavread('01.wav');speak2=wavread('02 matlab positive程序报错问题clc clearsyms t a k positivet>=0;a>0;k>1;R=(a.^k)/(t+a).^k;f=diff(1-R)lambda=f/RMTTF=int(R,t,0,inf)tmed=solve(R==0.5,t)新启动的matlab,第一次run 这个程序时候,为什么 我加入positive就没报错.第一 matlab求不定积分代码 matlab 开方运算 画图clc;x=0:0.1:15;y=sqrt(x*x-4*x+20)+sqrt(x*x+9);figureplot(x,y);报错为Error using ==> mtimesInner matrix dimensions must agree.Error in ==> suanshu at 3y=sqrt(x*x-4*x+20)+sqrt(x*x+9);figure 用matlab解方程求matlab代码. 请问谁有核聚类的matlab代码? sars的matlab拟合代码 求大神解答matlab矩阵问题我想求一个矩阵微分方程clc;clear;syms x1(t) x2(t) x;x=[x1;x2];c=[1 0;0 1];p1=1;p2=1;p=[p1;p2];dsolve(c*diff(x)==p,x1(0)==0,x2(0)==0)运行之后报错:CAT arguments dimensions are not consistent.我想问 Matlab 递归调用来隔离方程的根,怎么编写递归函数?用matlab隔离方程的根,认为如果两点间距小于0.1而且函数值反号,则认为这个区间存在一个方程的实根.代码如下:clc;clear;format long;p=[1,-5,3,1,-7, matlab画图,感觉画出的有问题!帮忙改或者直接给代码!半立方抛物线:clear all;clc;a=1/10;x=0:pi/50:2*pi;y=sqrt(a.*(x.^3));polar(x,y);笛卡儿叶形线:clear all;clc;a=1;t=0:pi/100:2*pi;x=(3.*a.*t)/(1+t.^3);y=(3.*a.*t.^2)/ (1+ 跪求Hough变换检测直线的MATLAB源代码如题,要能直接运行, haskell iomonad问题想要从控制台输入一个数字以下代码报错do{input