求助!两幅图象的联合灰度分布
哪位大虾会求两幅图象的联合灰度分布,我自己做的一个请大家帮我看看,循环不出来有没有简单一点的.我做的是先对一幅图象进行平移,得到图象w,然后w一点点移回去,在移的过程中求出两幅图象的互信息,要先求两幅图象的联合灰度分布概率,在运行过程中求联合灰度分布那里一直运行不出结果,请高手帮忙解决一下,急用!!!<BR>pic=imread('D:\MATLAB7\toolbox\images\imdemos\mr2.gif');<BR>pic1=zeros(256,256);<BR>for a=1:256<BR> for b=1:256<BR>if(pic(a,b)~=0) <BR> pic1(a-10,b-10)=pic(a,b);<BR>else<BR> pic1(a,b)=0;<BR> <BR> end<BR> end<BR>e=round(c(1));f=round(c(2));<BR>pic1=pic;<BR>w=zeros(256,256);<BR>for a=1:256<BR> for b=1:256<BR>if(pic(a,b)~=0) <BR> w(a-e,b-f)=pic(a,b);<BR>else<BR> w(a,b)=0;<BR> <BR> end<BR> end<BR>end<BR>k=reshape(pic1,1,256*256);<BR>l=reshape(w,1,256*256);<BR>u=zeros(256,256);<BR>for m=1:256<BR> for n=1:256<BR> p=0; <BR>fori=1:256*256<BR> if(k(i)==(m-1))&(l(i)==(n-1))<BR> p=p+1;<BR> end <BR>end<BR>u(m,n)=p/(256*256);<BR> end<BR>end<BR>p1=sum(u);<BR>p2=sum(u');<BR>fitness=zeros(256,256);<BR>for s=1:256<BR> for d=1:256<BR> if p1(s)==0|p2(d)==0|u(s,d)==0<BR> fitness(s,d)=0;<BR> else fitness(s,d)=u(s,d)*(log2(u(s,d)/(p1(s)*p2(d))));<BR> end<BR> end<BR>end<BR>fitness=sum(fitness);<BR>fitness=sum(fitness');回复:(meimeimao)求助!两幅图象的联合灰度分布
<P>重复了,建议版主删除</P>
页:
[1]