문제

I have a 2D matrix where each element holds a value of either 0, 1 or 2.

I plot it using surface:

surface(img)

Matlab automatically paints blue for the '0' pixels, green for '1' and red for '2'. Now i want to change the default colour, for example using white colour for '0' pixels. How can i do that?

도움이 되었습니까?

해결책

[0 0 0] is black, [1 1 1] is white, [0.5 0.5 0.5] is gray:

MAP = [1 1 1;0.5 0.5 0.5; 0 0 0];
surface(img),colormap(MAP)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top