YCbCr to RGB from matrix table
Solution 1
If you are asking how the formula is derived, you may want to search for "color coordinate systems". This page has a good discussion on the YCbCr space, in particular.
We know that almost any color can be represented as a linear combination of red, green, and blue. But you can transform (or "rotate") that coordinate system such that the three basis elements are no longer RGB, but something else. In the case of YCbCr, the Y layer is the luminance layer, and Cb and Cr are the two chrominance layers. Cb correlates more closely to blue, and Cr correlates more closely to red.
YCbCr is often preferred because the human visual system is more sensitive to changes in luminance than quantitatively equivalent changes in chrominance. Therefore, an image coder such as JPEG can compress the two chrominance layers more than the luminance layer, resulting in a higher compression ratio.
EDIT: I misunderstood the question. (You should edit it to clarify.) Here is the formula to get RGB from YCbCr, taken from the above link:
r = 1.0 * y' + 0 * cB + 1.402 * cR
g = 1.0 * y' - 0.344136 * cB - 0.714136 * cR
b = 1.0 * y' + 1.772 * cB + 0 * cR
Solution 2
I'm not going to account for the round
portion, but since M
looks invertible:
You can round the resulting vector.
Solution 3
http://www.fourcc.org/fccyvrgb.php has YUV to RGB conversions.
Solution 4
Y = 0.2126*(219/255)*R + 0.7152(219/255)*G + 0.0722*(219/255)*B + 16
CB = -0.2126/1.18556*(224/255)*R - 0.7152/1.8556(224/255)*G + 0.5*(219/255)*B + 128
CR = 0.5*(224/255)*R - 0.7152/1.5748(224/255)*G - 0.0722/1.5748*(224/255)*B + 128
![SunnyShah](https://i.stack.imgur.com/FJJTd.jpg?s=256&g=1)
SunnyShah
I solve machine learning problems with Java, R, JS, C++.
Updated on July 15, 2022Comments
-
SunnyShah almost 2 years
Below is a matrix to convert RGB to YCbCr. Can you tell me how can I get formula to convert YCbCr to RGB? I mean, I have YCbCr value available and I want to get RGB from it.
-
SunnyShah over 13 yearsThanks for quick answer, but question is about how to have YCbCr to RGB converion.
-
Eugene Smith over 13 yearsWhy are you not satisfied with this formula?
-
SunnyShah over 13 yearsI mean I have YCbCr available and I want to convert it to RGB.
-
SunnyShah over 13 yearsI have YCbCr aleready available, I just need a formula to convert that YCbCr to RGB. That formula should be based on above table.
-
SunnyShah over 13 yearsI have YCbCr aleready available, I just need a formula to convert that YCbCr to RGB. That formula should be based on above table.
-
Mark Ransom over 13 yearsNice link, but the formula is not quite right - as stated it's for values 0.0-1.0, not 0-255.
-
Mark Ransom over 13 years@Sunny, did you check the link? Both formulas are available.
-
Steve Tjoa over 13 yearsYes, good point. The link also contains the extra (yet simple) modification for [0,255].
-
SunnyShah over 13 years@Mark Ransom, But I want formula derived from above matrix only.
-
Mutant Bob over 7 yearsOne thing I overlooked while implementing the conversion is the scaling and origin concerns for y, u, and v mentioned in the "Crucial Little Facts" section.