Color Space conversion between RGB and YCbCr

Source: Internet
Author: User

YCbCr is a revision of YUV through scaling and offset. It can be seen as a subset of YUV. It is mainly used to optimize the transmission of color video signals, so that it is backward compatible with vintage black and white TVs. Compared with RGB video signal transmission, RGB requires three independent video signals to be transmitted at the same time ).

Y: brightness (luminance or Luma), that is, the gray scale value. The "brightness" is established through the RGB input signal by overlapping specific parts of the RGB signal.

U & V: chrominance or chroma, used to describe the image color and saturation, used to specify the pixel color. "Color" defines two aspects of color-tone and saturation, expressed by Cr and CB respectively.

CB: the difference between the blue part of the RGB input signal and the brightness value of the RGB signal.
Cr: the difference between the red part of the RGB input signal and the brightness value of the RGB signal.

In the following two formulas, the values of each component of RGB and YCbCr ranges from 0 to 255.

Convert RGB to YCbCr

This formula is from: Genesis microchip. gm6010/gm6015 Programming Guide [M]. California us: Genesis Microchip Company, 2002: 85-90

| Y | 16 | 65.738, 129.057, 25.06 | r |
| CB | = | 128 | + (1/256) * |-37.945-74.494 112.43 | * | G |
| Cr | 128 | 112.439-94.154-18.28 | B |

That is:

Y = 0.257 * r + 0.564 * g + 0.098 * B + 16
CB =-0.148 * R-0.291 * g + 0.439 * B + 128
Cr = 0.439 * R-0.368 * G-0.071 * B + 128

Convert YCbCr to RGB

This formula is from: Genesis microchip. gm6015 preliminary data sheet [M]. California us: Genesis Microchip Company, 200:33-34

| R | 298.082 0 408.58 | Y-16 |
| G | = (1/256) * | 298.082-100.291-208.12 | * | CB-128 |
| B | 298.082 516.411 0 | Cr-128 |

That is:

R = 1.164 * (Y-16) + 1.596 * (Cr-128)
G = 1.164*(Y-16)-0.392*(CB-128)-0.813 * (Cr-128)
B = 1.164 * (Y-16) + 2.017 * (CB-128)

 

From: http://estray2wandering.blogbus.com/logs/100329876.html

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.