开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜