开发者

Matlab RGB color representation ([255 255 255] and [1 1 1])

开发者 https://www.devze.com 2023-04-09 23:34 出处:网络
What\'s the difference between above two representa开发者_Python百科tion of white color? I\'m a bit confused, and how they are used?The two equivalent representations are

What's the difference between above two representa开发者_Python百科tion of white color? I'm a bit confused, and how they are used?


The two equivalent representations are

uint8([255 255 255])

and

double([1 1 1])

These are just the integer and floating-point representations. Note that uint8([1 1 1]) will be (almost) black and that double([255 255 255]) will usually cause an error.

Note that the integer version is only generally permitted by the image-handling functions, like imread, imwrite and image. Everything else will expect the floating-point representation.


These two representations of white color refer to the RGB color model in which Red, Green and Blue lights are added together (additive color model) to produce the desired color.

Each one of the three basic light is usually coded with an 8 bits integer which therefore ranges from 0 to 255 (0 meaning total absence of this light).

In Matlab, these codes are often normalized by 255 and are floats between 0 and 1. Note that this is not the case when you open an image using imread for exemple, so you have to be careful and refer to the relevant parts of the documentation.

Example: if you want to specify a particular color with an RGB code for a plot you can use plot(data,'color',[0 1 1]);. This plot your data with the color cyan (green+blue).

See Matlab color specification for other ways of specifying colors in Matlab.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号