www.pudn.com > segment_ga.rar > ksw.asv
function y=ksw(t,mingrayvalue,maxgrayvalue,hist1,HT)
%¼ÆËã×î¼ÑÖ±·½Í¼ìØ£¨KSWìØ£©
Pt=0;
for i=mingrayvalue:t
Pt=Pt+hist1(i+1);
end
Ht=0;
for i=mingrayvalue:t
if hist1(i+1)==0
temp=0;
else
temp=-hist1(i+1)*log(hist1(i+1));
end
Ht=Ht+temp;
end
if Pt==0 | Pt==1 % or(Pt==0,Pt==1)
H=0;
else
H=log(Pt*(1-Pt))+Ht/Pt+(HT-Ht)/(1-Pt);
end
y=H;