www.pudn.com > huiduzhifangtu.rar > jiaquanjulifa.m, change:2007-11-17,size:746b


%一般直方图加权距离法 
A0=imread('cancer11','bmp');  %读cancer第一组数据 
s=size(A0); 
B0=zeros(1,256); 
p_qd=0; 
for m=1:s(1) 
    for n=1:s(2) 
        for h=1:256 
            if(A0(m,n)==(h-1)) 
                B0(h)=B0(h)+1; 
            end 
        end 
    end 
end 
B0=B0/sum(B0);         %cancer灰度直方图数据 
 
A=imread('fatliver11','bmp');  %读fatliver第一组数据 
s=size(A); 
B=zeros(1,256); 
for m=1:s(1) 
    for n=1:s(2) 
        for h=1:256 
            if(A(m,n)==(h-1)) 
                B(h)=B(h)+1; 
            end 
        end 
    end 
end 
B=B/sum(B); 
 
for h=1:256 
    if((B(h)>0)&(B0(h)>0)) 
    p_qd=B(h)*(B(h)-B0(h))^2+p_qd; 
    else  
        p_qd=(B(h)-B0(h))^2+p_qd; 
    end 
end 
p_qd=p_qd^(1/2)