Ycrcb
Ycrcb is widely used in video compression and digital image processing. It is a color space based on human eyes.
In opencv, the formula for converting from RGB space to ycrcb space is as follows:
Note that the formula from RGB to ycrcb is not unique. Here, opencv only uses the formula in Intel IPP.
The Delta value is as follows:
Here we use 8-bit RGB channels as an example, that is, Delta takes 128. According to the formula above, the value range of Y is (0,255), the value range of Cr is (0.54768, 255.452315), and the value range of CB is (0.57548, 255.42452 ). Therefore, we have a great reason to think that the values of Y, Cr, and CB are almost (0,255 ).
From the above formula, if the image is black, that is, r = G = B = 0, you can calculate y = 0, Cr = CB = 128, note that CR and CB are not 0 at this time.
Ycrcb is as follows:
Figure 1 shows the RGB source image, and Figure 2 shows the Y component based on the RGB model. Figure 3 and figure 4 correspond to the CB and Cr components.
HSV
The HSV color space is used to describe more accurate color contact than RGB, and is easier to calculate.
The conversion from RGB color space to HSV color space is implemented as follows in opencv:
The RGB image, whether 8-bit or 16-bit, needs to be converted into a floating point, that is, its value ranges from 0 ~ Between 1. Therefore, the converted values of V and s also belong to 0 ~ 1, h belongs to 0 ~ 360 degrees.
The HSV values are as follows: