gpt4 book ai didi

matlab - 为什么在 Matlab 中通过 rgb2ycbcr 转换的 Y 在 [16, 235] 范围内?

转载 作者:行者123 更新时间:2023-12-02 03:48:11 25 4
gpt4 key购买 nike

Matlab中rgb2ycbcr的帮助文档是这样说的

If the input is uint8, YCBCR is uint8, where Y is in the range [16 235], and Cb and Cr are in the range [16 240].

据我所知,从RGB到YCbCr的转换公式是

Y   =     0.299  R + 0.587  G + 0.114  B
Cb = - 0.1687 R - 0.3313 G + 0.5 B + 128
Cr = 0.5 R - 0.4187 G - 0.0813 B + 128

设R=0,G=0,B=0,得到Y=0,不在[16,235]范围内。设R=255,G=255,B=0,则Cb=0.5,也不在[16, 240]范围内。

为什么 rgb2ycbcr 使 Y 在 [16,235] 范围内,使 Cb/Cr 在 [16,240] 范围内?

最佳答案

正如@jucestain 所说,Wikipedia 有一个答案:

Y' values are conventionally shifted and scaled to the range [16, 235] (referred to as studio swing) rather than using the full range of [0, 255] (referred to as full swing).
This confusing practice derives from the MPEG standards and explains why 16 is added to Y' and why the Y' coefficients in the basic transform sum to 220 instead of 255. U and V values, which may be positive or negative, are summed with 128 to make them always positive.

关于matlab - 为什么在 Matlab 中通过 rgb2ycbcr 转换的 Y 在 [16, 235] 范围内?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15561915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com