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 件のコメント
回答 (2 件)
Vidip
2024 年 12 月 27 日
I understand that you are using k-means for segmentation and want to assign different colors to each cluster. Please refer to the below MATLAB Answer which discusses about a apporoach which can be followed for the same: https://in.mathworks.com/matlabcentral/answers/561650-how-can-i-add-colors-to-a-k-means-gscatter-plot-based-on-a-certain-cluster
0 件のコメント
DGM
2024 年 12 月 27 日
Create a label array from the segmentation. Create a color table associating each label to a desired color -- either the mean color for each cluster or some arbitrarily chosen color. Then use labeloverlay() to apply both to the original image.
If the entire image is labeled, you don't need to use labeloverlay(), since the label array then constitutes an indexed color image. Just use ind2rgb() or use any one of the image formats which support indexed color.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Statistics and Machine Learning Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!