matlab 定义未知向量,向量为什么会有未定义的问题??

icon1.gif 向量为什么会有未定义的问题??

我编的程序,最后用到向量r,按说向量应该不用定义吧,可是不知为什么,一运行就显示

??? Undefined function or variable 'r'.

Error in ==> fengle at 248

r

请高人解答,谢谢!!急!!

以下是我的程序:

I=imread('ggg.bmp');

J1=I;

J2=I;

J3=I;

M1=rgb2gray(J1);

N1=histeq(M1);

for i=200:400

if N1(i,1)<50

Q=i;

end;

end;

I=double(I);

for i=1:480

for j=1:640

IR=I(i,j,1)/255;

IG=I(i,j,2)/255;

IB=I(i,j,3)/255;

k=0.21267/[0.21267*IR+0.71516*IG+0.07217*IB];

R=IR*k;

G=IG*k;

B=IB*k;

x=0.41245*R+0.35758*G+0.18042*B;

y=0.21267*R+0.71516*G+0.07217*B;

z=0.01933*R+0.11919*G+0.95023*B;

a=500*[myfun(x/0.95045)-myfun(y)];

b=200*[myfun(y)-myfun(z/1.08875)];

L=myfun(y)*116-16;

if (I(i,j,1)-I(i,j,3)>25)&(I(i,j,1)-I(i,j,2)>25)&(b/a>0)&(b/a<1/2)&(a^2+b^2>25)&i

J1(i,j,1)=255;

J1(i,j,2)=0;

J1(i,j,3)=0;

end;

end;

end;

for i=1:480

for j=1:640

if (I(i,j,1)-I(i,j,3)>25)&(I(i,j,1)-I(i,j,2)>25)

J2(i,j,1)=255;

J2(i,j,2)=255;

J2(i,j,3)=255;

end;

end;

end;

M2=rgb2gray(J2);

P=rgb2gray(J3);

N2=histeq(M2);

for i=200:400

if N2(i,1)<50

Q=i;

end;

end;

c=0;

A=0;

B=0;

for i=Q-50:Q-10

for j=2:630

if N2(i,j)<90&(N2(i-2,j)-N2(i,j)>35)&(N2(i+2,j)-N2(i,j)>35)

c=c+1;

A=A+j;

B=B+i;

end;

end;

end;

C=A/c;

D=B/c;

E=0;

F=0;

for i=Q-50:Q-10

for j=2:630

if N2(i,j)<90&(N2(i-2,j)-N2(i,j)>35)&(N2(i+2,j)-N2(i,j)>35)

E=E+(j-C)*(i-D);

F=F+(j-C)^2;

end;

end;

end;

G=E/F;

H=D-G*C;

for i=Q-50:Q-10

for j=2:630

if abs(G*j-i+H)/((G^2+1)^(1/2))<=0.5

J1(i,j,1)=255;

J1(i,j,2)=255;

J1(i,j,3)=255;

N2(i,j)=255;

P(i,j)=255;

end;

end;

end;%得到最底下的边框

for i=1:400

if N2(i,2)==255;

R=i;

end;

end;

c=0;

A=0;

B=0;

for i=R-160:R-120

for j=2:630

if N2(i,j)<90&(N2(i-2,j)-N2(i,j)>35)&(N2(i+2,j)-N2(i,j)>35)

c=c+1;

A=A+j;

B=B+i;

end;

end;

end;

C=A/c;

D=B/c;

E=0;

F=0;

for i=R-160:R-120

for j=2:640

if N2(i,j)<90&(N2(i-2,j)-N2(i,j)>35)&(N2(i+2,j)-N2(i,j)>35)

E=E+(j-C)*(i-D);

F=F+(j-C)^2;

end;

end;

end;

G=E/F;

H=D-G*C;

for i=R-160:R-120

for j=2:630

if abs(G*j-i+H)/((G^2+1)^(1/2))<=0.5

J1(i,j,1)=255;

J1(i,j,2)=255;

J1(i,j,3)=255;

N2(i,j)=255;

P(i,j)=255;

end;

end;

end;%得到最上面的边

for i=1:200

if N2(i,2)==255

S=i;

end;

end;

T=(R+S)/2;

T=fix(T);

for j=1:640

J1(T,j,1)=255;

J1(T,j,2)=255;

J1(T,j,3)=255;

N2(T,j)=255;

P(T,j)=255;

end;%得到中间的边

c=0;

A=0;

B=0;

for i=1:480

for j=1:640

if (I(i,j,1)-I(i,j,3)>25)&(I(i,j,1)-I(i,j,2)>25)

c=c+1;

A=A+j;

B=B+i;

end;

end;

end;

C=A/c;

D=B/c;

E=0;

F=0;

for i=1:480

for j=1:640

if (I(i,j,1)-I(i,j,3)>25)&(I(i,j,1)-I(i,j,2)>25)

E=E+(j-C)*(i-D);

F=F+(j-C)^2;

end;

end;

end;

G=E/F;

H=D-G*C;

for i=1:480

for j=10:630

if abs(G*j-i+H)/((G^2+1)^(1/2))<=0.5

if M2(i-25,j-2)-M2(i-25,j)>30&M2(i-25,j+2)-M2(i-25,j)>30&M2(i-25,j)<200&M2(i-26,j)<200&M2(i-24,j)<200&M2(i-25,j-1)<200&M2(i-25,j+1)<200&M2(i-26,j-1)<200&M2(i-26,j+1)<200&M2(i-24,j-1)<200&M2(i-24,j+1)<200

for k=i-200:i+50

J1(k,j,1)=255;

J1(k,j,2)=255;

J1(k,j,3)=255;

N2(k,j)=255;

P(k,j)=255;

end;

end;

end;

end;

end;%得到拟合的红线,与边框竖线的交叉点并上下延长

T=P;

h=1;

for i=1:Q

for j=10:630

if P(i,j)==255&P(i,j-1)==255&P(i,j+1)==255

p(h)=i;

h=h+1;

end;

end;

end;

U=min(p);

V=max(p);

for i=1:480

for j=1:640

if iV

P(i,j)=0;

J1(i,j,1)=0;

J1(i,j,2)=0;

J1(i,j,3)=0;

end;

end;

end;

h=1;

for i=5:Q

for j=1:640

if T(i,j)==255&T(i-1,j)==255&T(i+1,j)==255

q(h)=j;

h=h+1;

end;

end;

end;

X=min(q);

Y=max(q);

for i=1:480

for j=1:640

if jY

P(i,j)=0;

J1(i,j,1)=0;

J1(i,j,2)=0;

J1(i,j,3)=0;

end;

end;

end;

for i=1:480

for j=1:640

if J1(i,j,1)==255|(J1(i,j,1)==0&J1(i,j,2)==0&J1(i,j,2)==0)

else J1(i,j,1)=0;

J1(i,j,2)=0;

J1(i,j,3)=0;

end;

end;

end;

imwrite(J1,'vv.bmp');%得到只包含分数栏和分数的图片

k=(T+S)/2;

k=fix(k);

h=1;

for j=1:640

if J1(k,j,1)==255&J1(k,j,2)==255&J1(k,j,3)==255&J1(k,j+1,1)==0&J1(k,j+1,2)==0&J1(k,j+1,3)==0

r(h)=j;

h=h+1;

end;

end;

r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值