|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
程序是在这个论坛上找的,但是运行不对,我的图像是256级的灰度图像,在附件中。temp_m是100×100的unit8类型数据,经过im2double(temp_m)变换,代上graynum=256,dist=1,可以得出结果。但是结果是零矩阵,是怎么回事,还有程序中为什么for m=1:16
for n=1:16-dist都是循环到16呢,我是新手,请教各位高手。谢谢了。
function [mat_temp]=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 编辑 ] |
|