Audio and video basics color model

RGB color space:

The most typical and commonly used color model for hardware devices is the three primary color model, that is, the RGB model. Each color uses an 8-bit binary number (two hexadecimal numbers) to indicate the intensity of the color, where 0x00 indicates the weakest color intensity, and 0xff the strongest color intensity. When RGB are all 0xff, that is, the three primary colors are 0xffffff, the overall display is white, and when the three RGB primary colors are all 0x00, that is, the color is 0x000000, the image represents black. The model diagram is as follows: Insert picture description here
Figure 1 RGB color model

In the RGB color space, any color light F can be mixed and added using the three different components of R, G, and B, namely: F = R + G + B.

RGB color space can be divided into the following types according to the number of storage bytes occupied by each component in the computer:

(1) RGB555

RGB555 is a 16bit RGB format, each component is represented by 5bit, and the remaining one is not used

(2) RGB565

RGB565 is a 16bit RGB format, where R occupies 5bit, G occupies 6bit, and B occupies 5bit

(3) RGB24

RGB24 is a 24-bit RGB format, each component occupies 8bit, the value range is 0-255

(4) RGB32

RGB24 is a 32bit RGB format, each component occupies 8bit, the rest is alpha channel or not used.

YUV color space:

YUV (also known as YCrCb) is a color coding method adopted by the European television system. In modern color TV systems, three-tube color cameras or color CCD cameras are usually used to capture images, and then the color image signals obtained are separated, amplified and corrected to obtain RGB, and then the brightness signal Y and two are obtained through a matrix conversion circuit. There are three color difference signals RY (that is, U) and BY (that is, V). Finally, the transmitting end encodes a total of three signals of brightness and two color differences and sends them out on the same channel. This color representation method is the so-called YUV color space. The importance of YUV color space is that its luminance signal Y and chrominance signals U and V are separated. If there is only Y component and no U and V signal components, then it is a black and white grayscale image.

The main users of YUV optimize the transmission of color video signals to make it backward compatible with old-fashioned black-and-white TVs, compared with RGB video signal transmission. Its biggest advantage is that it only needs very little bandwidth (RGB requires three independent video signals to be transmitted at the same time). Where Y represents the brightness (Luminance or Luma), which is the grayscale value; while "U" and "V" represent the chroma (Chrominance or Chroma), which is used to describe the color and saturation of the image, and is used to specify the pixel s color. "Brightness" is established through the RGB input signal by superimposing certain parts of the RGB signal together. "Chroma" defines two aspects of color-hue and saturation, which are represented by Cr and Cb respectively. Among them, Cr reflects the difference between the red part of the RGB input signal and the brightness value of the RGB signal. And Cb reflects the difference between the blue part of the RGB input signal and the same brightness value of the RGB signal.

The conversion formula of YUV and RGB is:

Y = 0.299R+0.587G+0.114B
U = -0.147R – 0.289G + 0.436B
V = 0.615R – 0.515G -0.100B
R = Y + 1.14V
G = Y – 0.39U – 0.58V
B = Y + 2.03U

HSV color space :

HSV (Hue, Saturation, Value) is a color space created by AR Smith in 1978 based on the intuitive characteristics of colors, also known as the Hexcone Model. The color parameters in this model are: hue (H), saturation (S), and lightness (V).

Hue H

Measured by angle, the value range is 0°~360°, starting from red and counting in a counterclockwise direction, red is 0°, green is 120°, and blue is 240°. Their complementary colors are: yellow is 60°, cyan is 180°, and purple is 300°;

Saturation S

Saturation S indicates how close the color is to the spectral color. A color can be seen as the result of mixing a certain spectral color with white. Among them, the greater the proportion of the spectral color, the higher the degree of the color close to the spectral color, and the higher the saturation of the color. The saturation is high, and the color is deep and bright. The white light component of the spectral color is 0, and the saturation is the highest. Usually the value ranges from 0% to 100%. The larger the value, the more saturated the color.

Lightness V

Brightness indicates the brightness of the color. For the color of the light source, the value is related to the brightness of the luminous body; for the color of an object, this value is related to the transmittance or reflectance of the object. Usually the value ranges from 0% (black) to 100% (white). The three-dimensional representation of the HSV model evolved from the RGB cube. Imagine looking from the white vertex of the RGB along the diagonal of the cube to the black vertex, you can see the hexagonal shape of the cube. The hexagonal boundary represents color, the horizontal axis represents purity, and the lightness is measured along the vertical axis. The model diagram is as follows:
Insert picture description here
Insert picture description here
RGB to HSV conversion : Insert picture description here
HSV to RGB conversion:
Insert picture description here

Linux, C/C++ technology exchange group: [960994558] I have compiled some good learning books, interview questions from big companies, and popular technology teaching video materials to share in it (including C/C++, Linux, Nginx, ZeroMQ, MySQL) , Redis, fastdfs, MongoDB, ZK, streaming media, CDN, P2P, K8S, Docker, TCP/IP, coroutine, DPDK, etc.), you can add it yourself if you need it! ~Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_52622200/article/details/114708816