0

I am reading a book about yuv and rgb colorspace, it told me how YCbCr come out, these steps like this:

  1. R, G, B is a float number ranged 0.0~1.0
  2. use a grayscale method to convert RGB value to Lum value: Y = kr * R + kg * G + kb * B
  3. get a difference value between Y and RGB
    Cr = R - Y
    Cg = G - Y
    Cb = B - Y

the book said: Cb + Cr + Cg is a constant and so only two of the three chroma components need to be stored or transmitted since the third component can always be calculated from the other two.[1]

I don't understand it. could anyone make a explaination for me?

[1]: H.264 and MPEG-4 Video Compression - Iain E. G. Richardson - P16

krosshj
  • 855
  • 2
  • 11
  • 25
  • exact quote with reference please. *and context, context is vital.* quote could potentially have been quoted with mistakes, or whoever wrote the book made a mistake. – Christoph Rackwitz Jun 26 '23 at 02:12
  • The bold quote is clearly wrong or incomplete, as **Y** is also required to compute the third choma component from the other two. – Chris Dodd Jun 26 '23 at 02:50
  • @ChrisDodd: but Y is the grayscale,so separated from chroma. You should get used on such sloppy descriptions of colours (also on many books which should know better). And so this comment is also for the OP: forget precision on most books. (also most calculations are not done in the linear space, so extra errors are done, but that come from analog television time). – Giacomo Catenazzi Jun 26 '23 at 08:30
  • @GiacomoCatenazzi YCbCr is purely a mathematical transformation, so linearity doesn't matter. When you convert back to RGB you'll get the same numbers back. – Mark Ransom Jun 26 '23 at 12:01
  • @MarkRansom: right, but so you lose the meaning of "chroma": changing luminosity (a normal creative intent) you change chroma. it is all right if done consistently, but books are mostly inconsistent. So for MPEG4 it doesn't matter, but if you are doing special effects, it matters. (Note: the question tagged YUV, where linearity matter). – Giacomo Catenazzi Jun 26 '23 at 12:57
  • link to the book: https://doc.lagout.org/network/H.264%20and%20MPEG4%20Video%20Compression.pdf (pdf page 42) – Christoph Rackwitz Jun 26 '23 at 13:00
  • book looks like a first edition, with little review. Authors probably meant to express something like "the third component directly depends on the other two". definitely a flaw in the book. – Christoph Rackwitz Jun 26 '23 at 13:13

1 Answers1

1

Look at the equations:

Cr = R - Y
Cg = G - Y

If you have Cr, Cg and Y, you can compute R and G. And with R, G and Y you can compute R from the relation

Y = kr * R + kg * G + kb * B

So, Cb = B - Y is redundant. You can use the same logic to see that you need any two of the three chroma components.

The statement “Cb + Cr + Cg is constant” does not make much sense to me, it is obviously false.

Cb + Cr + Cg = R + G + B - 3*Y =
= (1-3*kr) * R + (1-3*kg) * G + (1-3*kb) * B

If the three k values are all 1/3, then the sum is 0, but in general, the sum of the three chroma components depends on the color.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120