YCoCg

From HandWiki
Revision as of 16:57, 6 February 2024 by Jport (talk | contribs) (url)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The YCoCg color model, also known as the YCgCo color model, is the color space formed from a simple transformation of an associated RGB color space into a luma value (denoted as Y) and two chroma values called chrominance green (Cg) and chrominance orange (Co). It is supported in video and image compression designs such as H.264/MPEG-4 AVC, HEVC, VVC, JPEG XR, and Dirac.[1] It is simple to compute, has good transform coding gain, and can be losslessly converted to and from RGB with fewer bits than are needed with other color models. A reversible scaled version with even lower bit depth, YCoCg-R, is also supported in most of these designs and is also used in Display Stream Compression. The more complete definition with variable bit depths of Y and chrominance values is given in ITU-T H.273.

Original image above and representation of the individual components Y, chrominance green Cg and chrominance orange Co.

History and naming

The earliest documents (circa 2003) referred to this color model as YCoCg.[2][3] It was adopted in an international standard for the first time in H.264/AVC (in its second edition professional extensions project[4]), which had primarily been designed to use the YCbCr color model. When it was adopted it was noted that the Co component carried the deviation toward red and was thus more similar to Cr than Cb, so the signal assignment and the naming was switched in the standard, resulting in the YCgCo alternative name (YCgCo is used in ITU-T H.273).

Properties

Advantages the YCoCg color model has over the YCbCr color model are simpler and faster computation, better decorrelation of the color planes to improve compression performance, and exactly lossless invertibility.[5][6]

Conversion with the RGB color model

The three values of the YCoCg color model are calculated as follows from the three color values of the RGB color model:[2] [math]\displaystyle{ \begin{bmatrix} Y \\ Co \\ Cg \end{bmatrix} = \begin{bmatrix} \frac{1}{4} & \frac{1}{2} & \frac{1}{4} \\ \frac{1}{2} & 0 & -\frac{1}{2} \\ -\frac{1}{4} & \frac{1}{2} & -\frac{1}{4}\end{bmatrix} \cdot \begin{bmatrix} R \\ G \\ B \end{bmatrix} }[/math]

The values of Y are in the range from 0 to 1, while Co and Cg are in the range of −0.5 to 0.5, as is typical with "YCC" color models such as YCbCr. For example, pure red is expressed in the RGB system as (1, 0, 0) and in the YCoCg system as (1/4, 1/2, −1/4).[5][6] However, since the coefficients of the transformation matrix are simple binary fractions, it is easier to compute than other YCC transformations. For RGB signals with bit depth n, either the resulting signals would then be rounded to n bits or would ordinarily be n+2 bits when processing data in this form (although n+1 bits would be sufficient for Co).

The inverse matrix converts from the YCoCg color model back to the RGB color model: [math]\displaystyle{ \begin{bmatrix} R \\ G \\ B \end{bmatrix} = \begin{bmatrix} 1 & 1 & -1 \\ 1 & 0 & 1 \\ 1 & -1 & -1\end{bmatrix} \cdot \begin{bmatrix} Y \\ Co \\ Cg \end{bmatrix} }[/math]

To perform the inverse conversion, only two additions and two subtractions are necessary, with integer-valued coefficients, by implementing it as:

tmp = Y   - Cg;
R   = tmp + Co;
G   = Y   + Cg;
B   = tmp - Co;

The lifting-based YCoCg-R variation

A scaled version of the transformation, sometimes called YCoCg-R (where the "-R" refers to reversibility),[7] can be implemented efficiently with a reduced bit depth. The scaled version uses a lifting scheme to make it exactly invertible while minimizing the bit depth of the three color components. For RGB signals with bit depth n, the bit depth of the Y signal when using YCoCg-R will be n and the bit depth of Co and Cg will be n+1, as contrasted with ordinary YCoCg which would need n+2 bits for Y and Cg and n+1 bits for Co.[8]

Here, possible values for Y are still in [0, 1], while possible values for Co and Cg are now in [-1, 1].

The conversion from RGB to YCoCg-R is: Template:Flex columns The conversion from YCoCg-R to RGB is then: Template:Flex columns

(All divisions are truncating, as in C. The forward transformation may be adapted to produce a similar implementation of YCoCg.)

It is also possible to pack all three elements in 3n bits using modulo arithmetic.[9] However, the resulting discontinuity at wraparound can confuse subsequent stages of compression.[10][11]

Efficiency gains

The screen content coding (SCC) extensions of the HEVC (H.265) standard and the VVC (H.266) standard include an adaptive color transform within the residual coding process that corresponds with switching the coding of RGB video into the YCoCg-R domain. Use of YCoCg color space to encode RGB video in HEVC-SCC found large (~20%) coding gains for lossy video, but minimal gains when using YCoCg-R to losslessly encode video.[12]

The reversible variant gives 4.21 dB of coding gain, compared to 3.54 dB for the BT.470 color matrix and 3.98 dB for the JPEG 2000 reversible color transform.[8][2]

Literature

References

  1. "Dirac Specification" (pdf). BBC. pp. 136. http://diracvideo.org/download/specification/dirac-spec-latest.pdf. 
  2. 2.0 2.1 2.2 Henrique Malvar and Gary Sullivan, "Transform, Scaling & Color Space Impact of Professional Extensions". Moving Picture Experts Group and Video Coding Experts Group document JVT-H031, JVT 8th meeting, Geneva, May 2003.
  3. Shijun Sun, "Residual Color Transform Using YCoCg-R". Moving Picture Experts Group and Video Coding Experts Group document JVT-L014, 12th JVT meeting: Redmond, Washington, United States, July 2004.
  4. Woo-Shik Kim, Dmitry Birinov, and Dae-Sung Cho, Hyun Mun Kim (Multimedia Lab, Samsung AIT), "Enhancements to RGB coding in H.264/MPEG-4 AVC FRExt". Video Coding Experts Group document VCEG-Z16, 26th VCEG meeting: Busan, Korea, April 2005.
  5. 5.0 5.1 "YCoCg: A Color Space with RGB Reversibility" (ppt). University of Texas at Arlington. http://www-ee.uta.edu/dip/Courses/EE5356/YCgCo-Presentation.ppt. 
  6. 6.0 6.1 Yair Moshe. "H.264 Amendment: Fidelity Range Extensions" (pdf). Signal and Image processing Lab (SIPL), Technion Israel Institute of Technology. pp. 15. http://sipl.technion.ac.il/new/Archive/Special_Events/H264-2004/H264-FR-Extensions.pdf. 
  7. Henrique Malvar and Gary Sullivan, "YCoCg-R: A color space with RGB reversibility and low dynamic range". Moving Picture Experts Group and Video Coding Experts Group document JVT-I014, JVT PExt Ad Hoc Group Meeting: Trondheim, Norway, July 2003.
  8. 8.0 8.1 Malvar, Henrique S.; Sullivan, Gary J.; Srinivasan, Sridhar (28 August 2008). "Lifting-based reversible color transformations for image compression". Optical Engineering + Applications, 2008. pp. 707307. doi:10.1117/12.797091. https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/2008_ColorTransforms_MalvarSullivanSrinivasan.pdf. 
  9. Cary, David. "Lossless RGB to Y'CbCr transformation" (in en). https://stackoverflow.com/a/12146329. 
  10. Tilo Strutz, "Multiplierless Reversible Colour Transforms and their Automatic Selection for Image Data Compression." IEEE Transactions on Circuits and Systems for Video Technology, Vol. 23, No. 7, pp. 1249–1259, July 2013.
  11. Tilo Strutz and Alexander Leipnitz, "Reversible Colour Spaces without Increased Bit Depth and Their Adaptive Selection." IEEE Signal Processing Letters, Vol. 22, No. 9, pp. 1269–1273, September 2015.
  12. "Overview of HEVC extensions on screen content coding". September 2015. p. 8. https://www.researchgate.net/publication/282175661_Overview_of_HEVC_extensions_on_screen_content_coding.