matlab:具有指定颜色的曲面图

时间:2013-12-16 00:02:34

标签: matlab figure

我有一个2D矩阵,其中每个元素的值为0,1或2。

我使用surface绘制它:

surface(img)

Matlab自动为'0'像素绘制蓝色,绿色为'1',红色为'2'。现在我想更改默认颜色,例如使用白色作为“0”像素。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:3)

[0 0 0]为黑色,[1 1 1]为白色,[0.5 0.5 0.5]为灰色:

MAP = [1 1 1;0.5 0.5 0.5; 0 0 0];
surface(img),colormap(MAP)
相关问题