出错:Undefined function or variable 'g'
f1=rgb2ycbcr(imread('01.jpg'));=g(f1);f2=rgb2ycbcr(imread('02.jpg'));=g(f2);
f3=rgb2ycbcr(imread('03.jpg'));=g(f3);
f4=rgb2ycbcr(imread('04.jpg'));=g(f4);
f5=rgb2ycbcr(imread('05.jpg'));=g(f5);
f6=rgb2ycbcr(imread('06.jpg'));=g(f6);
f7=rgb2ycbcr(imread('07.jpg'));=g(f7);
f8=rgb2ycbcr(imread('08.jpg'));=g(f8);
cb=cat(1,cb1,cb2,cb3,cb4,cb5,cb6,cb7,cb8);
cr=cat(1,cr1,cr2,cb3,cb4,cb5,cb6,cb7,cr8);
m=mean()
n=cov()
以上程序代码运行过程中,总提示“Undefined function or variable 'g'”
请教下!
[ 本帖最后由 eight 于 2007-7-13 13:35 编辑 ] 原帖由 guaike1314 于 2007-7-13 10:10 发表 http://www.chinavib.com/forum/images/common/back.gif
f1=rgb2ycbcr(imread('01.jpg'));=g(f1);
f2=rgb2ycbcr(imread('02.jpg'));=g(f2);
f3=rgb2ycbcr(imread('03.jpg'));=g(f3);
f4=rgb2ycbcr(imread('04.jpg'));=g(f4);
...
建议看看各个置顶贴,并仔细阅读 我改成了这样,可是,还是有问题啊
f1=rgb2ycbcr(imread('01.jpg'));
f2=rgb2ycbcr(imread('02.jpg'));
f3=rgb2ycbcr(imread('03.jpg'));
f4=rgb2ycbcr(imread('04.jpg'));
f5=rgb2ycbcr(imread('05.jpg'));
f6=rgb2ycbcr(imread('06.jpg'));
cb1=f1(: : 2);
cr1=f1(: : 2);
cb2=f2(: : 2);
cr2=f2(: : 2);
cb3=f3(: : 2);
cr3=f3(: : 2);
cb4=f4(: : 2);
cr4=f4(: : 2);
cb5=f5(: : 2);
cr5=f5(: : 2);
cb6=f6(: : 2);
cr6=f6(: : 2);
cb=cat(1,cb1,cb2,cb3,cb4,cb5,cb6);
cr=cat(1,cr1,cr2,cb3,cb4,cb5,cb6);
m=mean()
n=cov()
m =
Empty matrix: 1-by-0
Warning: Divide by zero.
(Type "warning off MATLAB:divideByZero" to suppress this warning.)
> In C:\MATLAB6p5\toolbox\matlab\datafun\cov.m at line 61
??? Error using ==> -
Function '-' is not defined for values of class 'uint8'.
Error in ==> C:\MATLAB6p5\toolbox\matlab\datafun\cov.m
On line 61==> xc = x - repmat(sum(x)/m,m,1);% Remove mean
看的都晕晕的!!!
可还是新手啊!
[ 本帖最后由 eight 于 2007-7-13 17:02 编辑 ] 原帖由 guaike1314 于 2007-7-13 15:53 发表 http://www.chinavib.com/forum/images/common/back.gif
我改成了这样,可是,还是有问题啊
f1=rgb2ycbcr(imread('01.jpg'));
f2=rgb2ycbcr(imread('02.jpg'));
f3=rgb2ycbcr(imread('03.jpg'));
f4=rgb2ycbcr(imread('04.jpg'));
f5=rgb2ycbcr(imread('05.jpg') ...
求 cov 前先把变量转换为数值型 OK我放弃了哪个,重新写了这个,没错了哦:victory:
%第一步:在Matlab中进行统计建模并计算出均值m和协方差n
f1=imread('01.bmp');
f1_ycbcr=rgb2ycbcr(f1);
f1_ycbcr=double(f1_ycbcr);
fcb1=f1_ycbcr(:,:,2);
fcr1=f1_ycbcr(:,:,3);
=size(f1_ycbcr);
cb1=reshape(fcb1,1,m1*n1);
cr1=reshape(fcr1,1,m1*n1);
f2=imread('02.bmp');
f2_ycbcr=rgb2ycbcr(f2);
f2_ycbcr=double(f2_ycbcr);
fcb2=f2_ycbcr(:,:,2);
fcr2=f2_ycbcr(:,:,3);
=size(f2_ycbcr);
cb2=reshape(fcb2,1,m2*n2);
cr2=reshape(fcr2,1,m2*n2);
f3=imread('03.bmp');
f3_ycbcr=rgb2ycbcr(f3);
f3_ycbcr=double(f3_ycbcr);
fcb3=f3_ycbcr(:,:,2);
fcr3=f3_ycbcr(:,:,3);
=size(f3_ycbcr);
cb3=reshape(fcb3,1,m3*n3);
cr3=reshape(fcr3,1,m3*n3);
f4=imread('04.bmp');
f4_ycbcr=rgb2ycbcr(f4);
f4_ycbcr=double(f4_ycbcr);
fcb4=f4_ycbcr(:,:,2);
fcr4=f4_ycbcr(:,:,3);
=size(f4_ycbcr);
cb4=reshape(fcb4,1,m4*n4);
cr4=reshape(fcr4,1,m4*n4);
f5=imread('05.bmp');
f5_ycbcr=rgb2ycbcr(f5);
f5_ycbcr=double(f5_ycbcr);
fcb5=f5_ycbcr(:,:,2);
fcr5=f5_ycbcr(:,:,3);
=size(f5_ycbcr);
cb5=reshape(fcb5,1,m5*n5);
cr5=reshape(fcr5,1,m5*n5);
cb=cat(2,cb1,cb2,cb3,cb4,cb5);
cr=cat(2,cr1,cr2,cr3,cr4,cr5);
h=mean2(cb);
k=mean2(cr);
m=
n=cov(cb,cr)
已经在使用中了
谢谢老8了哦
页:
[1]