How can I change each pixel value in a cluster using k-means algorithm to different colors

1 view (last 30 days)
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'

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jun 2016
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 Comments
Frank
Frank on 23 Jun 2016
I do calculate the means per cluster and I sort the clusters in ascending order, however I am not sure what you mean by "index that sort index at the array of cluster indices". Could you please clarify?

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!