求助,灰度图像共生矩阵计算中出现的问题
程序是在这个论坛上找的,但是运行不对,我的图像是256级的灰度图像,在附件中。temp_m是100×100的unit8类型数据,经过im2double(temp_m)变换,代上graynum=256,dist=1,可以得出结果。但是结果是零矩阵,是怎么回事,还有程序中为什么for m=1:16for n=1:16-dist都是循环到16呢,我是新手,请教各位高手。谢谢了。
function =compute(temp_m,graynum,dist)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:graynum
for j=1:graynum
matH(i,j)=0;matV(i,j)=0;matRD(i,j)=0;matLD(i,j)=0;
end
end
double total;total=0;
for m=1:16
for n=1:16
newimage(m,n)=ceil(temp_m(m,n)/(256/graynum));
end
end
%%% 0
for m=1:16
for n=1:16-dist
matH(newimage(m,n),newimage(m,n+dist))=matH(newimage(m,n),newimage(m,n+dist))+1;
matH(newimage(m,n+dist),newimage(m,n))=matH(newimage(m,n+dist),newimage(m,n))+1;
end
end
%%%%%%%%%%%%%%% 90
for m=1:16-dist
for n=1:16
matV(newimage(m,n),newimage(m+dist,n))=matV(newimage(m,n),newimage(m+dist,n))+1;
matV(newimage(m+dist,n),newimage(m,n))=matV(newimage(m+dist,n),newimage(m,n))+1;
end
end
%%%%%%%%%%%%%%%%%%% 135
for m=1:16-dist
for n=16-dist
matLD(newimage(m,n),newimage(m+dist,n+dist))= matLD(newimage(m,n),newimage(m+dist,n+dist))+1;
matLD(newimage(m+dist,n+dist),newimage(m,n))= matLD(newimage(m+dist,n+dist),newimage(m,n))+1;
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 45
for m=dist:16
for n=1:16-dist
matRD(newimage(m,n),newimage(m-dist+1,n+dist))=matRD(newimage(m,n),newimage(m-dist+1,n+dist))+1;
matRD(newimage(m-dist+1,n+dist),newimage(m,n))=matRD(newimage(m-dist+1,n+dist),newimage(m,n))+1;
end
end
%%%%%%%%%%%%%%
for m=1:graynum
for n=1:graynum
total=total+matH(m,n);
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for m=1:graynum
for n=1:graynum
mat_temp(m,n)=matH(m,n)/total;
mat_temp(m,n)=double(mat_temp(m,n));
end
end
%%%%over
[ 本帖最后由 wenyanzi 于 2007-3-9 17:12 编辑 ] 怎么没人理我啊,大家帮帮忙吧,谢谢了。 double total;total=0;
语法错误了吧?你用的是matlab吧
[ 本帖最后由 eight 于 2007-3-10 19:49 编辑 ] 是matlab 啊,怎么错了呢,还有16什么意思。谢谢 原帖由 wenyanzi 于 2007-3-10 19:57 发表
是matlab 啊,怎么错了呢,还有16什么意思。谢谢
matlab不支持 double total; 这样的定义,你还是先看看最基础的语法吧。至于16那里,前面已经出错了,后面也没有意义。不过如果按照dist=1,n应该循环到15而已,不知道你那里是什么问题 谢谢了,自己再看看吧
页:
[1]