Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an image classification problem. I have an image which spesify classes' labels using "imread" funtion of Matlab $(A=imread('r.bmp'))$ the output for example for 3 classes is as $$A= \begin{matrix} 1 & 1 & 1& 2& 2&2 &3&3& 3 \\ 1 & 1 & 1& 2& 2&2 &3&3& 3 \\ 1 & 1 & 1& 2& 2&2 &3&3& 3 \end{matrix}$$ How can I use "colormap" function of matlab to generate an image with specified color for each class??(i.e. each class in this image is specified with different color) can anyone help me to solve this problem? Thank you!

share|cite|improve this question
Maybe try this question in StackOverflow, as it is more a programming question (and SO is much more active) – Ander Biguri Dec 5 '12 at 8:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.