A formula of color: how does MATLAB link indexed value of color with RGB format?

2 次查看(过去 30 天)
As known, MATLAB can plot graphics with colorbar and chosen colormap and also read/write images in RGB-scheme. And two color model are used, indexed (defined by double type C in range 0..1) and RGB.
How easy to define analytically function F:C->(R,G,B), i.e. r=r(c),g=g(c),b=b(c)?
With natural aasumptions: F(0)=(0,0,0),F(1)=(1,1,1) and F(?)=(1,0,0),.. F(?)=(0,1,1)
It would be helpful for intellectual colormaps....

采纳的回答

Jan
Jan 2012-1-18
As far as I know, you cannot map colors to a single parameter using an analytical function. The RGB colorspace uses 3 componnts, which cannot be projected onto a line.
The standard method is a lookup table using colormap.
Java can use a 24 bit value as a RGB color applying something like this
RGB = uint8(floor(rand(40, 20, 3) * 256));
Ind = RGB(:, 1) + 256 * RGB(:,2) + 65535 * RGB(:, 3);
Usually the alpha channel is added also and the colors are stored with 32 bits.
What do you want to achieve?
  1 个评论
Igor
Igor 2012-1-18
I think that simplest way to define this "like as" analytic function (thank you for code) is:
fist byte of C -- R-value
second -- G
third -- B
fourth (power) -- transparency
And the goal is achieved.
But it's interesting to imagine such function F as math formula.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by