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


%中心距法 
A0=imread('cancer11','bmp');  %读cancer第一组数据 
s=size(A0); 
B0=zeros(1,256); 
m1_q=0;m2_q=0;m3_q=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灰度直方图数据 
for h=1:256 
    m1_q=m1_q+B0(h); 
end 
m1_q=m1_q/256 
for h=1:256 
    m2_q=m2_q+(B0(h)-m1_q)^2; 
end 
m2_q=(m2_q/256)^(1/2) 
for h=1:256 
    m3_q=m3_q+(B0(h)-m1_q)^3; 
end 
m3_q=(m3_q/256)^(1/3) 
 
     
 
 
A=imread('fatliver11','bmp');  %读fatliver第一组数据 
s=size(A); 
B=zeros(1,256); 
m1_d=0;m2_d=0;m3_d=0; 
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 
    m1_d=m1_d+B(h); 
end 
m1_d=m1_d/256 
for h=1:256 
    m2_d=m2_d+(B(h)-m1_d)^2; 
end 
m2_d=(m2_d/256)^(1/2) 
for h=1:256 
    m3_d=m3_d+(B(h)-m1_d)^3; 
end 
m3_d=(m3_d/256)^(1/3) 
 
p_qd=((m1_q-m1_d)^2+(m2_q-m2_d)^2+(m3_q-m3_d)^2)^(1/2)