Domanda

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?

È stato utile?

Soluzione

[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)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top