K均值聚类,颜色聚类,显示

来源:互联网 发布:怎么克隆网站软件 编辑:程序博客网 时间:2024/06/03 16:41
[FileName,PathName]=uigetfile('*.*');
Img=imread(strcat(PathName,FileName));  
[row col dim]=size(Img);
imshow(Img);

RGB = reshape(Img, [row*col 3]);

 RGB = double(RGB);

[FId FCClusters] = kmeans(RGB, 5, 'emptyaction','singleton');

 FId=reshape(FId,row,col);

figure;imagesc(FId)