声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1387|回复: 5

[图像处理] 求助~高手进来看下这个源码哪里错了啊~我是做的基于FCM的图象分割

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

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

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

x
<P>帮帮我啊~在某网上下的源码~说是FCM的图象分割~可以分割,灰度图,索引图,彩图<BR>可是程序会在报错,在eval那~是不是要在这''',file, '''输入图象的名称啊?不懂啊~<BR>我是菜鸟!<BR><BR><BR>function fcmapp(file, cluster_n)<BR>% FCMAPP<BR>% fcmapp(file, cluter_n) segments a image named file using the algorithm<BR>% FCM.<BR>% [in]<BR>%   file: the path of the image to be clustered.<BR>%   cluster_n: the number of cluster for FCM.<BR><BR>eval(['info=imfinfo(''',file, ''');']);<BR>switch info.ColorType<BR>    case 'truecolor'<BR>        eval(['RGB=imread(''',file, ''');']);<BR>%       [X, map] = rgb2ind(RGB, 256);<BR>        I = rgb2gray(RGB);<BR>        clear RGB;<BR>    case 'indexed'<BR>        eval(['[X, map]=imread(''',file, ''');']);<BR>        I = ind2gray(X, map);<BR>        clear X;<BR>    case 'grayscale'<BR>        eval(['I=imread(''',file, ''');']);<BR>end;<BR>I = im2double(I);<BR>filename = file(1 : find(file=='.')-1);<BR>data = reshape(I, numel(I), 1);<BR><BR>tic<BR>[center, U, obj_fcn]=fcm(data, cluster_n);<BR>elapsedtime = toc;<BR><BR>%eval(['save(', filename, int2str(cluster_n),'.mat'', ''center'', ''U'', ''obj_fcn'', ''elapsedtime'');']);<BR>fprintf('elapsedtime = %d', elapsedtime);<BR><BR>maxU=max(U);<BR>temp = sort(center, 'ascend');<BR>for n = 1:cluster_n;<BR>    eval(['cluster',int2str(n), '_index = find(U(', int2str(n), ',:) == maxU);']);<BR>    index = find(temp == center(n));<BR>    switch index<BR>        case 1<BR>            color_class = 0;<BR>        case cluster_n<BR>            color_class = 255;<BR>        otherwise<BR>            color_class = fix(255*(index-1)/(cluster_n-1));<BR>    end<BR>    eval(['I(cluster',int2str(n), '_index(:))=', int2str(color_class),';']);<BR>end;<BR>filename = file(1:find(file=='.')-1);<BR>I = mat2gray(I);<BR>%eval(['imwrite(I,', filename,'_seg', int2str(cluster_n), '.bmp'');']);<BR>imwrite(I, 'temp\tu2_4.bmp');<BR>imview(I);<BR></P>
回复
分享到:

使用道具 举报

发表于 2006-4-19 10:09 | 显示全部楼层
<P>关注</P>
发表于 2006-4-20 19:10 | 显示全部楼层

回复:(菜肉包子)求助~高手进来看下这个源码哪里错了...

你是不是直接运行了?这个函数是用来调用的<BR><BR>比如说工作目录下有一个文件a.jpg<BR><BR>那么在命令串口运行fcmapp('a.jpg',3)
发表于 2006-4-21 09:40 | 显示全部楼层
<P> 运行出错如下:<BR>Error in ==&gt; stepfcm at 27<BR>obj_fcn = sum(sum((dist.^2).*mf));  % objective function</P>
<P>Error in ==&gt; fcm at 88<BR> [U, center, obj_fcn(i)] = stepfcm(data, U, cluster_n, expo);</P>
<P>Error in ==&gt; fcmapp at 28<BR>[center, U, obj_fcn]=fcm(data, cluster_n);<BR></P>
发表于 2006-4-21 21:51 | 显示全部楼层

回复:(菜肉包子)求助~高手进来看下这个源码哪里错了...

错误提示是什么?我这里没碰到这样的错误
发表于 2008-12-24 09:26 | 显示全部楼层
高手啊!!!
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-22 23:22 , Processed in 0.055677 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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