MATLAB: How can an color image can be changed have only four color in desire area.

plz any one can reply.

Hello , i am doing with image segmentation and have an gray image segmented with only four different intensity level .Now how can be it convert to four different color rgb format.

Best Answer

[indimg, map] = rgb2ind(YourImage, 4);
newimg = ind2rgb(indimg, map);