How do RGB values from 0 to 1 get converted to a number from 0 to 255?

53 ビュー (過去 30 日間)
Anna
Anna 2014 年 8 月 28 日
回答済み: Tabitha 2014 年 8 月 28 日
Is the RGB value simply scaled to a number from 0 to 255 to determine the colour of a pixel on the screen?

回答 (2 件)

Image Analyst
Image Analyst 2014 年 8 月 28 日
RGB images have 3 color channels (planes). The values in each plane can be in the range of 0-255 if you want to display them.
  3 件のコメント
Adam
Adam 2014 年 8 月 28 日
It is a simple linear mapping. I don't know off-hand whether [0.5 0.5 0.5] maps to [128 128 128] or [127 127 127], but the scaling is definitely linear.
Image Analyst
Image Analyst 2014 年 8 月 28 日
編集済み: Image Analyst 2014 年 8 月 28 日
The color of the pixel is 3 numbers for R, G, and B. If you're displaying them on the screen, they must be uint8 which means they'll be in the range 0-255. Of course you can work with any range you want (0-1 or -999 to +12345 or whatever) or even floating point values internal to your program - nothing wrong with that. But to display you'll need to scale into the range 0-255 and cast to uint8.

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


Tabitha
Tabitha 2014 年 8 月 28 日

カテゴリ

Help Center および File ExchangeRed についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by