How can I change each pixel value in a cluster using k-means algorithm to different colors
1 次查看(过去 30 天)
显示 更早的评论
I am using k-means for segmentation and I have five clusters. I analyze each clusters and find the mean value of each cluster. I then sort each cluster based on the mean value in ascending order. What I want to do is make each pixel value associated with a cluster a different color (e.g. cluster1 = 'red', cluster2 = 'green', cluster3 = 'brown', cluster4 = 'cyan', cluster5 = 'yellow'
0 个评论
采纳的回答
Walter Roberson
2016-6-22
Each pixel will resulted in a cluster index. reshape() that data into rows and columns. image() the result. Then
cmap = [1 0 0; 0 1 0; 0.5 0.25 0.07; 0 1 1; 1 1 0];
colormap(cmap)
4 个评论
Walter Roberson
2016-6-24
[sorted_means, sort_idx] = sort(cluster_means);
remapped_idx = sort_idx(idx);
image(remapped_idx);
colormap(cmap);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!