Setting Custom Colors Using imagesc function
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am using imagesc() to look at different sections of a matrix of 0's, 1's, and 2's. Imagesc sets the lowest value (always 0 in this case) to blue, the largest value to red, and the intermediate value to green. Some sections of the matrix have all three values (0,1,2), some have only 0 and 1, and some have only 0 and 2. I want to have set colors for 1 and 2 (0 is always blue). For example, when the section of matrix has only 0 and 1, the 1's show up red. When the section of matrix has only 0 and 2, the 2's show up red. I want the 1's to always show up green and the 2's to always show up red, despite whether there are only 1's or only 2's in the section of matrix. Any suggestions? Thanks.
0 commentaires
Réponses (1)
Walter Roberson
le 17 Nov 2011
colormap([0 0 1; 0 1 0; 1 0 0]);
image(uint8(YourArray))
0 commentaires
Voir également
Catégories
En savoir plus sur Color and Styling dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!