I applied k-mean clustering on a preprocessed image using the following matlab code
%B - input image
C=rgb2gray(B);
[idx centroids]=kmeans(double(C(:)),4);
imseg = zeros(size(C,1),size(C,2));
for i=1:max(idx)
imseg(idx==i)=i;
end
i=mat2gray(imseg);
% i - output image
Every time I display the output, color assigned to the output images changes. How can I give a specific color to cluster1, cluster2, cluster3 and cluster4.