| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1614 人关注过本帖
标题:这个源码哪里错了啊~我是做的基于FCM的图象分割
只看楼主 加入收藏
菜肉包子
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-4-15
收藏
 问题点数:0 回复次数:2 
这个源码哪里错了啊~我是做的基于FCM的图象分割
帮帮我啊~在某网上下的源码~说是FCM的图象分割~可以分割,灰度图,索引图,彩图
可是程序会在报错,在eval那~是不是要在这''',file, '''输入图象的名称啊?不懂啊~
我是菜鸟!


function fcmapp(file, cluster_n)
% FCMAPP
% fcmapp(file, cluter_n) segments a image named file using the algorithm
% FCM.
% [in]
% file: the path of the image to be clustered.
% cluster_n: the number of cluster for FCM.

eval(['info=imfinfo(''',file, ''');']);
switch info.ColorType
case 'truecolor'
eval(['RGB=imread(''',file, ''');']);
% [X, map] = rgb2ind(RGB, 256);
I = rgb2gray(RGB);
clear RGB;
case 'indexed'
eval(['[X, map]=imread(''',file, ''');']);
I = ind2gray(X, map);
clear X;
case 'grayscale'
eval(['I=imread(''',file, ''');']);
end;
I = im2double(I);
filename = file(1 : find(file=='.')-1);
data = reshape(I, numel(I), 1);

tic
[center, U, obj_fcn]=fcm(data, cluster_n);
elapsedtime = toc;

%eval(['save(', filename, int2str(cluster_n),'.mat'', ''center'', ''U'', ''obj_fcn'', ''elapsedtime'');']);
fprintf('elapsedtime = %d', elapsedtime);

maxU=max(U);
temp = sort(center, 'ascend');
for n = 1:cluster_n;
eval(['cluster',int2str(n), '_index = find(U(', int2str(n), ',:) == maxU);']);
index = find(temp == center(n));
switch index
case 1
color_class = 0;
case cluster_n
color_class = 255;
otherwise
color_class = fix(255*(index-1)/(cluster_n-1));
end
eval(['I(cluster',int2str(n), '_index(:))=', int2str(color_class),';']);
end;
filename = file(1:find(file=='.')-1);
I = mat2gray(I);
%eval(['imwrite(I,', filename,'_seg', int2str(cluster_n), '.bmp'');']);
imwrite(I, 'temp\tu2_4.bmp');
imview(I);
搜索更多相关主题的帖子: FCM 源码 图象 
2006-04-15 11:39
iihdd
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-1-5
收藏
得分:0 
这只是函数,相当于c++的类,缺少主文件
2010-01-05 17:00
flylee
Rank: 5Rank: 5
等 级:职业侠客
帖 子:309
专家分:374
注 册:2004-8-10
收藏
得分:0 
2010-01-05 19:22
快速回复:这个源码哪里错了啊~我是做的基于FCM的图象分割
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014039 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved