声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1682|回复: 1

[图像处理] fcm的编程,可是不出结果

[复制链接]
发表于 2007-4-23 15:21 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
clear all
I=imread('1_24018.bmp');        
imshow(I);

count=imhist(I);   
[m,n]=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)
for  i=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;
for  i=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熟悉的高手帮忙看一下,为什么没有结果~~~拜托了 !!
回复
分享到:

使用道具 举报

发表于 2007-4-23 15:32 | 显示全部楼层
原帖由 suddy123456 于 2007-4-23 15:21 发表
clear all
I=imread('1_24018.bmp');        
imshow(I);

count=imhist(I);   
[m,n]=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 ...


请按照置顶贴:聚宝盆 把你的问题信息补充完整,你这样子叙述问题(特别是没有提供图片,没有出错提示)谁也帮不了你
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-19 05:37 , Processed in 0.076259 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表