I'm currently working on project which is related with color quantization.The algorithm implies as initial step k-means algorithm . My code untill now :
N = 10;
K=7;
I=imread('baboon.bmp');
Idouble = double(I);
mat=zeros(size(I,1)*size(I,2),size(I,3));
R=I(:,:,1);
G=I(:,:,2);
B=I(:,:,3);
mat(:,1)=R(:);
mat(:,2)=G(:);
mat(:,3)=B(:);
[IDX,CENTERS] = kmeans(mat,N);
Next step in the algorithm is finding the most popular color(the color which contains the most pixels in the image) . It seems very easy but somewhat I get stuck when I tried to extract that from IDX
variable .