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

What is the difference between the two representations of white? I'm a little confused and how are they used?

+4
source share
2 answers

Two equivalent representations:

uint8([255 255 255]) 

and

 double([1 1 1]) 

It is just integers and floating point. Note that uint8([1 1 1]) will be (almost) black and that double([255 255 255]) usually causes an error.

Please note that the integer version is usually only allowed with image processing functions such as imread , imwrite and image . Everything else awaits floating point waiting.

+5
source

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 obtain the desired color.

Each of the three main sources is usually encoded with an 8-bit integer, so it ranges from 0 to 255 (0 means the complete absence of this light).

In Matlab, these codes often normalize to 255 and float between 0 and 1. Note that this is not the case when you open an image using imread , for example, you must be careful and refer to the relevant parts of the documentation.

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

See Matlab color specification for other ways to specify colors in Matlab.

+4
source

All Articles