单独的红色和紫色像素的照片
2视图(30天)
显示旧的评论
答案(2)
Rushikesh四氨基二苯醚
2014年9月5日
试图分离出的颜色使用k - means聚类使用指南
http://www.mathworks.in/help/images/examples/color-based-segmentation-using-k-means-clustering.html
input_im = imread (“T2.jpg”);
sz_im =大小(input_im);
cform = makecform (“srgb2lab”);
lab_he = applycform (input_im cform);
ab =双(lab_he (:,: 2:3));
nrows =大小(ab, 1);
ncols =大小(ab, 2);
ab =重塑(ab nrows * ncols 2);
nColors = 3;
%重复集群3次,以避免局部最小值
[cluster_idx, cluster_center] = kmeans (ab、nColors“距离”,“sqEuclidean”,…
“复制”3);
pixel_labels =重塑(cluster_idx、nrows ncols);
imshow (pixel_labels[])、标题(集群的图像标记指数”);
segmented_images =细胞(1、3);
rgb_label = repmat (pixel_labels [1 1 3]);
为k = 1: nColors
颜色= input_im;
颜色(rgb_label ~ = k) = 0;
segmented_images {k} =颜色;
结束
为k = 1: nColors
图
title_string = sprintf (“集群% d对象”、k);
imshow (segmented_images {k})、标题(title_string);
结束
提供的结果如下:
希望这可以帮助!