To use computers to represent and process colors, you must use quantitative methods to describe colors, that is, to create a color model. Currently, three color models are widely used: computing color models, industrial color models, and visual color models. The color model is also known as the color model of color, which is mainly used for pure theoretical research and computation. The industrial color model focuses on the Implementation Technology of practical application; the visual color model is used for the color model and control that are directly interface with people.
1. color models include RGB, XYZ, luv, LCH, lab, UCS, and uvw of CIE.
2. RGB, YUV, yiq, CMYK, and YCbCr of the industrial color model NTSC.
3. Visual color models include the HS * series, including HSL and HSV (B ).
Common color formula/matrix:
1,RGB <-> CIE XYZ
A. RGB <-> cie xyz rec601
| X | 0.607 0.174 0.201 | r |
| Y | = | 0.299 0.587 0.114 | * | G |
| Z | 0.000 0.066 1.117 | B |
| R | 1.910-0.532-0.288 | x |
| G | = |-0.985 1.999-0.028 | * | Y |
| B | 0.058-0.118 0.898 | z |
B. RGB <-> CIE XYZ rec709
| X | 0.412 0.358 0.180 | r |
| Y | = | 0.213 0.715 0.072 | * | G |
| Z | 0.019 0.119 0.950 | B |
| R | 3.241-1.537-0.499 | x |
| G | = |-0.969 1.876-0.042 | * | Y |
| B | 0.056-0.204 1.057 | z |
C. RGB <-> CIE XYZ ITU
| X | = | 0.431 0.342 0.178 | r |
| Y | = | 0.222 0.707 0.071 | * | G |
| Z | = | 0.020 0.130 0.939 | B |
| R | 3.063-1.393-0.476 | x |
| G | = |-0.969 1.876 0.042 | * | Y |
| B | 0.068-0.229 1.069 | z |
2,RGB <-> CMYK
A. RGB-> CMYK
K = min (1-r, 1-g, 1-B)
C = (1-r-k)/(1-k)
M = (1-g-k)/(1-k)
Y = (1-b-k)/(1-k)
B. CMYK-> RGB
R = 1-min (1, C * (1-k) + k)
G = 1-min (1, m * (1-k) + k)
B = 1-min (1, y * (1-k) + k)
3,RGB-> CIE RGB
| Rcie | 1.167-0.146-0.151 | r |
| Gcie | = | 0.144 0.753 0.159 | * | G |
| Bcie |-0.001 0.059 1.128 | B |
4,Cie xyz-> CIE Lab
D65 xn = 0.312713, yn = 0.329016
L = 116 * (y/yn) ^ (1/3) y/YN> 0.008856
L = 903.3 * Y/YN y/YN <= 0.008856
A = 500 * (f (x/XN)-f (y/yn ))
B = 200 * (f (y/yn)-f (z/Zn ))
5,RGB-> HSV
V = max (R, G, B)
S = (V-min (R, G, B) * 255/V if V! = 0, 0 otherwise
(G-B) * 60/s, if v = r
H = 180 + (B-r) * 60/s, if v = G
240 + (r-g) * 60/s, if v = B
If H <0, H = H + 360
Use the formula from 0 ° to 360 ° above to calculate the hue values, so that they can be used for 8 bits after being divided by 2.
6,RGB <-> yiq
Yiq is used by the North American TV System (NTSC. Y indicates the brightness, I and Q indicate the color and saturation of the image.
| Y | 0.299 0.587 0.114 | r |
| I | = | 0.596-0.274-0.322 | * | G |
| Q | 0.211-0.523 0.312 | B |
| R | 1 0.956 0.621 | Y |
| G | = | 1-0.272-0.647 | * | I |
| B |-1-1.106-1.703 | q |
7,RGB <-> YUV
YUV is used by European television systems (PAL ). Y indicates the brightness, and U and V indicate the color.
| Y | 0.299 0.587 0.114 | r |
| U | = |-0.148-0.289 0.437 | * | G |
| V | 0.615-0.515-0.100 | B |
| R | 1 0 1.140 | Y |
| G | = | 1-0.395-0.581 | * | I |
| B |-1 2.032 0 | q |
8,RGB <-> YCbCr
The JPEG color model is YCbCr. It is derived from the YUV color model. Y indicates the brightness, while CB and Cr adjust u and v a little.
| Y | 0.2990 0.5870 0.1140 0 | r |
| CB |-0.1687-0.3313 0.5000 128 | * | G |
| Cr | = | 0.5000-0.4187-0.0813 128 | B |
| 1 | 0 0 0 1 | 1 |
| R | 1 1.40200 0 | Y |
| G | = | 1-0.34414-0.71414 | * | CB-128 |
| B | 1 1.77200 0 | Cr-128 |