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

2 ビュー (過去 30 日間)
Igor
Igor 2012 年 1 月 18 日
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 Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by