2014-04-04 121 views
-1

我有颜色矢量= [0 ..... 1]。我想将其转换为RGB代码,以便强度到RGB颜色转换器,matlab

color_vector =[0.....1] % o for blue, .5 for green and 1 for red 
R=255,0,0 
G=0,255,0 
B=0,0,255 

是否有任何matlab命令(我找不到)做它或代码。

另一个问题是,我想让我自己的绿色范围(.45-.55)都应该是绿色。

回答

0

我使用CC和它的作品well.I可以插值的颜色。

2

基本上你所描述的是colormap - 但你需要为你的颜色向量索引 。

顺便提及hsv2rgb产生类似的颜色映射。但是,从红色开始:

作为色调从0变化为1时,所得到的颜色从红色 ,通过黄色,绿色,青色,蓝色和品红色变化,返回到红色。

1

对于不完全为0,0.45-0.55或1的强度值,你想在颜色之间进行线性插值吗?如果是这样,你可以使用real2rgb(在MATLAB文件交换),如下:

I = rand(100, 100);        % Input data 
cmap = [1 0 0 45; 0 1 0 10; 0 1 0 45; 0 0 1 0]; % Colormap defining the transformation 
RGB = real2rgb(I, cmap);       % Do the conversion 
+0

@ user664303我有一个向量[x,y,z,intensity],我想要[x,y,z,rgb]。我不知道如何使用real2rgb。 – Shahgee