fcm的编程,可是不出结果
clear allI=imread('1_24018.bmp');
imshow(I);
count=imhist(I);
=size(I);
h=count/(m*n);
N=m*n;
V1=zeros(4);
V2=zeros(4);
m=2;
c=4;
r=0.01;
U1=zeros(c,N);
V1(1)=0;
V1(2)=110;
V1(3)=197;
V1(4)=254;
I=double(I);
diedai=1;
while (diedai==1)
fori=1:256;
if (i-V1(1))^2>0.01&(i-V1(2))^2>0.01&(i-V1(3))^2>0.01&(i-V1(4))^2>0.01
tep1=(i-V1(1))^2;
tep2=(i-V1(2))^2;
tep3=(i-V1(3))^2;
tep4=(i-V1(4))^2;
U1(1,i)=1.0/(1+(tep1/tep2)^(1.0/(m-1))+(tep1/tep3)^(1.0/(m-1))+(tep1/tep4)^(1.0/(m-1)));
U1(2,i)=1.0/(1+(tep2/tep1)^(1.0/(m-1))+(tep2/tep3)^(1.0/(m-1))+(tep2/tep4)^(1.0/(m-1)));
U1(3,i)=1.0/(1+(tep3/tep1)^(1.0/(m-1))+(tep3/tep2)^(1.0/(m-1))+(tep3/tep4)^(1.0/(m-1)));
U1(4,i)=1.0/(1+(tep4/tep1)^(1.0/(m-1))+(tep4/tep2)^(1.0/(m-1))+(tep4/tep3)^(1.0/(m-1)));
else
for k=1:c
if (i-V1(k))^2<0.01
U1(k,i)=1.0;
else
U1(k,i)=0.0;
end
end
end
tep1=0.0;
tep2=0.0;
tep3=0.0;
tep4=0.0;
tep5=0.0;
tep6=0.0;
tep7=0.0;
tep8=0.0;
fori=1:256
tep1=tep1+ h(i)*(i)*U1(1,i)^m;
tep2=tep2+ h(i)*U1(1,i)^m;
tep3=tep3+ h(i)*(i)*U1(2,i)^m;
tep4=tep4+ h(i)*U1(2,i)^m;
tep5=tep5+ h(i)*(i)*U1(3,i)^m;
tep6=tep6+ h(i)*U1(3,i)^m;
tep7=tep7+ h(i)*(i)*U1(4,i)^m;
tep8=tep8+h(i)*U1(4,i)^m;
end
V2(1)=tep1/tep2;
V2(2)=tep3/tep4;
V2(3)=tep5/tep6;
V2(4)=tep7/tep8;
for j=1:c
if (V1(j)-V2(j))^2<0.01
diedai=0;
else
V1(j)=V2(j);
end
end
I1=zeros(m,n);
for i=1:m
for j=1:n
if (I(i,j)-V2(1))^2>(I(i,j)-V2(2))^2
I1(i,j)= V2(2);
else if (I(i,j)-V2(2))^2>(I(i,j)-V2(3))^2
I1(i,j)= V2(3);
else if (I(i,j)-V2(3))^2>(I(i,j)-V2(4))^2
I1(i,j)= V2(4);
else I1(i,j)= V2(1);
end
end
end
I1=uint8(I1); % 转换为无符号型整数 8表示8位二进制整数范围0~255
imshow(I1);
麻烦对FCM熟悉的高手帮忙看一下,为什么没有结果~~~拜托了 !! 原帖由 suddy123456 于 2007-4-23 15:21 发表
clear all
I=imread('1_24018.bmp');
imshow(I);
count=imhist(I);
=size(I);
h=count/(m*n);
N=m*n;
V1=zeros(4);
V2=zeros(4);
m=2;
c=4;
r=0.01;
U1=zeros(c,N);
V1(1 ...
请按照置顶贴:聚宝盆 把你的问题信息补充完整,你这样子叙述问题(特别是没有提供图片,没有出错提示)谁也帮不了你
页:
[1]