How can I change each pixel value in a cluster using k-means algorithm to different colors
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Vidip
el 27 de Dic. de 2024
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 comentarios
DGM
el 27 de Dic. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!