为什么Cr+Cg+Cb是常数?

huangapple go评论64阅读模式
英文:

Why Cr+Cg+Cb is constant?

问题

我正在阅读一本关于YUV和RGB颜色空间的书,它告诉我YCbCr是如何产生的,步骤如下:

  1. R、G、B是在0.0~1.0范围内的浮点数。
  2. 使用灰度方法将RGB值转换为亮度值:Y = kr * R + kg * G + kb * B。
  3. 获取Y和RGB之间的差值:
    Cr = R - Y
    Cg = G - Y
    Cb = B - Y

这本书说:Cb + Cr + Cg是一个常数,因此只需要存储或传输三个色度分量中的两个,因为第三个分量始终可以从其他两个分量计算得出。[1]

我不太理解这句话。是否有人可以为我解释一下?

[1]: H.264和MPEG-4视频压缩 - Iain E. G. Richardson - 第16页

英文:

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

答案1

得分: 1

看这些方程式:

Cr = R - Y
Cg = G - Y

如果你有Cr、Cg和Y,你可以计算出R和G。然后通过R、G和Y,你可以用以下关系计算R:

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

所以,Cb = B - Y 是多余的。你可以使用相同的逻辑来看出你只需要三个色度分量中的任意两个。

这个陈述“Cb + Cr + Cg 是常数”对我来说没有太多意义,显然是错误的。

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

如果三个k值都是1/3,那么总和为0,但一般来说,三个色度分量的总和取决于颜色。

英文:

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.

huangapple
  • 本文由 发表于 2023年6月26日 09:18:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76553017.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定