FCM图像分割算法MATLAB源代码.docx
《FCM图像分割算法MATLAB源代码.docx》由会员分享,可在线阅读,更多相关《FCM图像分割算法MATLAB源代码.docx(6页珍藏版)》请在第一文库网上搜索。
1、FCM图像分割算法function fcmapp(file, cluster_n)% FCMAPP% fcmappffile, 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.ColorTypecase ruecoloreval(,RGB=imread(,zfi
2、le,%X, map = rgb2ind(RGB, 256);I = rgb2gray(RGB);clear RGB;case indexedeval(X, maptimread(二file,I = ind2gray(X, map);clear X;case grayscale1eval(l=imread( file,););end;I = im2double(l);filename = file(l: find(file=.)-l);data = reshape(l, numel(l), 1);ticcenter, U, obj_fcn=fcm(data, cluster_n);elapse
3、dtime = toe;%eval(save(/ filename, int2str(cluster_n)/.mat, center, U, obj_fcnz elapsedtime);1);fprintf(elapsedtime = %d,elapsedtime);maxll=max(U);temp = sort(center, Ascend1);for n = l:cluster_n;eval(,cluster,int2str(n)/ Jndex = find(U(, int2str(n)z= maxU););index = find(temp = center(n);switch ind
4、excase 1color_class = 0;case cluster ncolor_class = 255;otherwisecolor_class = fix(255*(index-l)/(cluster_n-l);endeval(l(clusterJnt2str(n)z ,_ndex(:)=/ int2str(color_class)/;);end;filename = file(l:find(file=.)-l);I = mat2gray(l);%eval(imwrite(l/z filenameJ-Seg, int2str(cluster_n), .bmp););imwritefl
5、, ,temptu2_4.bmp,/bmp,);imview(l);function fcmapp(file, cluster_n)% FCMAPP% fcmappffile, 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.ColorTypecase
6、truecoloreval(RGB=imread(,/file/ ););%X, map = rgb2ind(RGB, 256);I = rgb2gray(RGB);clear RGB;case indexedeval(X, maptimread(二file,I = ind2gray(X, map);clear X;case grayscaleeval(l=imread( file,););end;I = im2double(l);filename = file(l: find(file=.)-l);data = reshape(l, numel(l), 1);ticcenter, U, ob
7、j_fcn=fcm(data, cluster_n);elapsedtime = toe;%eval(save(,filenamej int2str(cluster_n),mat”center: UJobj_fcnJelapsedtime););fprintf(elapsedtime = %d,elapsedtime);maxU=max(U);temp = sort(center, Ascend1);for n = l:cluster_n;eval(cluster/int2str(n)/ Jndex = find(U(,int2str(n),= maxU););index = find(tem
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- FCM 图像 分割 算法 MATLAB 源代码