Confused about the RGB colour coding

Hello, I wonder if the Matlab RGB color index is just the usual RGB index divided by 255??? The default RGB color list is as follows in Matlab:
For example green is [0 1 0] the default RGB coding in the Colour software like Photoshop is [0 255 0] so do I just divide the color coding in Photoshop RGB format by 255 to arrive at the Matlab RGB color code?
I wonder if there is an inbuilt function like that... Thanks! D

 採用された回答

Jan
Jan 2011 年 9 月 29 日

1 投票

If you store the RGB values as a [X, Y, 3] DOUBLE array, the values are going form 0 to 1. If you use an UINT8 array, the values are in the interval [0, 255], as in many other applications (Photoshop, color-pickers, HTML, etc).
A simple conversion:
RGB_double = rand(200, 100, 3);
RGB_uint8 = uint8(RGB * 255 + 0.5);
The 0.5 cares for the same weights of the UINT8(0) and UINT8(255) bins.
See also: im2double and im2uint8.

3 件のコメント

Dima
Dima 2011 年 9 月 29 日
THANK YOU FOR YOUR ANSWER....I wonder if there is a function that can transform the usual format in the Photoshop for example to the Matlab format? for example I have this colour in Photoshop
0, 204, 255 which corresponds to [0 0.8 1] in Matlab.....do I just divide the vector manually typed from Photoshop by 255 to arrive at the Matlab color?
thanks!))
Image Analyst
Image Analyst 2011 年 9 月 29 日
Yes. Dividing by 255 is fine. Or by intmax('uint16') if you're using 16 bit numbers.
Walter Roberson
Walter Roberson 2011 年 9 月 29 日
im2double() does the type-checking and divides by the appropriate scaling factor.

サインインしてコメントする。

その他の回答 (0 件)

タグ

質問済み:

2011 年 9 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by