1. 程式人生 > >YCbCr色彩空間 (筆記1)

YCbCr色彩空間 (筆記1)

色彩空間用數學方式來描述顏色集合,常見的2個基本色彩模型是RGB,YUB.

    • RGB - Used in computer graphics

    • YCbCr - Used in video compression

1.1 YCbCr

    YCbCr 則是在世界數字組織視訊標準研製過程中作為ITU - R BT.601 建議的一部分,其實是YUV經過縮放和偏移的翻版。其中Y與YUV 中的Y含義一致,Cb,Cr 同樣都指色彩,只是在表示方法上不同而已。YCbCr或Y'CbCr色彩空間通常會用於影片中的影像連續處理,或是數字攝影系統中,其中Y是指亮度(luma)分量(灰階值),Cb指藍色色度分量,而Cr指紅色色度分量。

    醫學研究證明,人的肉眼對視訊的Y分量更敏感,因此在通過對色度分量進行子取樣來減少色度分量後,肉眼將察覺不到的影象質量的變化。如果只有Y訊號分量而沒有U、V分量,那麼這樣表示的影象就是黑白灰度影象。彩色電視採用YUV空間正是為了用亮度訊號Y解決彩色電視機與黑白電視機的相容問題,使黑白電視機也能接收彩色電視訊號。

    

    RGB is not very efficient (有效)in terms of(就......而言) bandwidth(頻寬) as (因為)all the three components have to be present in equal bandwidth to produce(produce) any color. So an RGB based frame buffer(幀緩衝器) must have same pixel depth(畫素深度) and display resolution for each RGB component.

    YCbCr easy to get rid of(擺脫) some redundant color information(冗餘的顏色資訊), it is used in image and video compression standards like JPEG, MPEG1, MPEG2 and MPEG4.

    YCbCr主要的子取樣格式有 YCbCr 4:2:0、YCbCr 4:2:2 和 YCbCr 4:4:4。

  • 4:4:4 – In this, there is no sub-sampling of the chroma components(色度分量的子取樣), and can be as well referred and used(被引用和使用) directly as a RGB image. High-end cameras  devices use this format to not lose any data.
  • 4:2:2 – The chroma components(色度分量) are horizontally sub-sampled (被水平次取樣) and their resolution (解析度,解析度)is halved (減半)as compared to(與x相比) the luminance counterpart (亮度對應)in this scheme(該方案). High-end digital video formats and still images(靜態影象)generally employ(採用,employment 僱傭)this scheme.
  • 4:2:0 – In this variant(變種), the chroma components are sub-sampled by a factor of 2, both horizontally as well as vertically(水平方向和垂直方向), thus (因此)reducing to a factor (因子)of a quarter(1/4). The standard video compression MPEG uses this scheme。

1.2  YCbCr - RGB Color Format Conversion

    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. In many cases the complete possible range (完整可能範圍)of 8 bit is used, 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(8-bit RGB to 8-bit YCbCr):

       

    These equations can be implemented in fixed-point arithmetic as follows:

        y = (77 × r + 150 × g + 29 × b)/256

       cb = (-43 × r - 85 × g + 128 × b + 32768)/256

       cr = (128 × r - 107 × g - 21 × b + 32768)/256

    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: