IOS rgb yuv 转换

原文地址:http://www.equasys.de/colorconversion.html

Color Conversion

This page contains the different equations for converting one of the luminance / chrominance based color formats (YUV, YCbCr and YPbPr) into the RGB color format and vice versa.

YUV - RGB Color Format Conversion

YCbCr - RGB Color Format Conversion
YPbPr - RGB Color Format Conversion
See also the page Color Formats to get basic information about the different color formats.

YUV - RGB Color Format Conversion
The YUV color format is used only for analog PAL or analog NTSC video - not for any digital video format. The following equation describes the conversion of an RGB color into the YUV color format:
这里写图片描述
This is the inverse matrix to get the RGB components out of the YUV color:
这里写图片描述

YCbCr - RGB Color Format Conversion

For digital component video the color format YCbCr is used. For standard definition TV applications (SDTV) the following equation describes the color conversion from RGB to YCbCr (according to ITU-R BT.601):
这里写图片描述
To recover an RGB color from a YCbCr color, the following inverse matrix is used:
这里写图片描述
The possible range of values for chrominance and luminance reserves some footroom and headroom, which is necessary to provide some space for overshooting, e.g. in combination with analog video equipment. For computer based applications using RGB and YCbCr color formats, in many cases the complete possible range of 8 bit is used, without providing a footroom or headroom. Typically, this full-range color format is used for JPEG images.

The conversion of RGB colors into full-range YCbCr colors is described by the following equation:
这里写图片描述
The other way round, to convert a full-range YCbCr color into RGB is described by the following equation:
这里写图片描述
For high definition TV (HDTV), different coefficients are used. The possible range of values is identical to the SDTV, to provide the necessary footroom and headroom. The following equation describes the color conversion from RGB to YCbCr for HDTV (according to ITU-R BT.709):
这里写图片描述
This is the corresponding inverse matrix to get the RGB color components out of a YCbCr color:
这里写图片描述

YPbPr - RGB Color Format Conversion

The following equations describe the conversion from RGB to YPbPr color format for component analog video and vice versa. Again, different coefficients are used for SDTV and HDTV.

In case of SDTV, for converting RGB to YPbPr, the following matrix is used:
这里写图片描述
This is the inverse matrix to recover an RGB value from a given YPbPr value:
这里写图片描述
In case of HDTV, for converting RGB to YPbPr, the following matrix is used:
这里写图片描述
Finally, this is the inverse matrix:
这里写图片描述

记录该信息,以备不时之需;顺便说一句:
在ios平台使用avcompositon 合成视频,利用 avassertoutput 导出视频的时候,不论如何设置video output settings ,最终输出的 CVImageBuffer 都是 bt.702 格式,和AVPlayerItemOutput 不太一样,后者输出为bt.601,GPUImage 本没有提供 702FullRange(0 - 255) 转换矩阵,上述网站也未提供相应的转换矩阵,最终我们使用非FullRange 矩阵做了视频转换,导致我们合成的视频,颜色有些失真,和原始的图像有些差别,直接复用 601FullRange 转换,可以弱化这种失真

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值