Setting Custom Colors Using imagesc function

조회 수: 5 (최근 30일)
Kristen
Kristen 2011년 11월 17일
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.

답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 17일
colormap([0 0 1; 0 1 0; 1 0 0]);
image(uint8(YourArray))

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by