Index Matrix to RGB Matrix
2 views (last 30 days)
Hi. I have calculated the index matrix from kmeans clustering algorithm. My data set have 16 class and every class is indexed in the matrix. Also my data coming from a image so I have a 145x145 image matrix with variables changing from 1 to 16. I want to color every class in the image. I would be appreciated if you could help me. Thanks.
Note: I have added the matrix.
Ameer Hamza on 22 Jun 2020
Which colormap do you want to use. For example, try this
cmap = summer(16);
rgb_imag = ind2rgb(ind_fin, cmap);
Image Analyst on 22 Jun 2020
Here's one way
s = load('kmeansclusteredindex.mat')
ind_fin = s.ind_fin;
subplot(2, 1, 1);
title('Original Image', 'FontSize', 20);
customColorMap = jet(16); % Use whatever colormap you want.
subplot(2, 1, 2);
title('Histogram', 'FontSize', 20);
xlabel('Class Number', 'FontSize', 20);
ylabel('Pixel Count', 'FontSize', 20);