为什么在Matlab中由rgb2ycbcr转换的Y在[16,235]范围内? [英] Why is the Y, converted by rgb2ycbcr in the Matlab, in the range [16, 235]?

查看:458
本文介绍了为什么在Matlab中由rgb2ycbcr转换的Y在[16,235]范围内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Matlab中 rgb2ycbcr 的帮助文档说

The help document of the rgb2ycbcr in Matlab says that

如果输入为uint8,则YCBCR为uint8,其中Y在[16]范围内 235],而Cb和Cr在[16240]范围内.

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的转换公式为

As I know, the conversion formula from RGB to YCbCr is

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]范围内.

Let R=0, G=0 and B=0, we get Y=0, which is not in the range [16,235]. And let R=255, G=255 and B=0, we get Cb=0.5, which is also not in the range [16, 240].

为什么 rgb2ycbcr 将Y设置在[16,235]范围内并将Cb/Cr设置在[16,240]范围内?

Why rgb2ycbcr make Y in the range [16,235] and make Cb/Cr in the range [16,240]?

推荐答案

正如@jucestain所说,

As @jucestain said, there is a answer from the Wikipedia:

通常将Y'值移动并缩放到[16,235]范围(称为工作室摆动),而不是使用[0,255]的整个范围(称为完整摆动).
这种令人困惑的做法源自MPEG标准,并解释了为什么在Y'中添加16,以及为什么基本变换中的Y'系数总和为220,而不是255.U和V值(可以为正也可以为负)与128求和使他们永远保持积极态度.

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中由rgb2ycbcr转换的Y在[16,235]范围内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆