菜肉包子 发表于 2006-4-15 11:30

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

<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>% <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>%       = rgb2ind(RGB, 256);<BR>      I = rgb2gray(RGB);<BR>      clear RGB;<BR>    case 'indexed'<BR>      eval(['=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>=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>

lcx1975 发表于 2006-4-19 10:09

<P>关注</P>

happy 发表于 2006-4-20 19:10

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

你是不是直接运行了?这个函数是用来调用的<BR><BR>比如说工作目录下有一个文件a.jpg<BR><BR>那么在命令串口运行fcmapp('a.jpg',3)

lcx1975 发表于 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> = stepfcm(data, U, cluster_n, expo);</P>
<P>Error in ==&gt; fcmapp at 28<BR>=fcm(data, cluster_n);<BR></P>

happy 发表于 2006-4-21 21:51

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

错误提示是什么?我这里没碰到这样的错误

xiaoyu1218 发表于 2008-12-24 09:26

高手啊!!!
页: [1]
查看完整版本: 求助~高手进来看下这个源码哪里错了啊~我是做的基于FCM的图象分割