Basic Learning notes opencv (20): Color Space in opencv (ing ...)

Source: Internet
Author: User

 

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:

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.