You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

寻求近似CbCr的可逆RGB颜色变换以实现无损图像压缩

Approximating Y'CbCr with a Reversible 8-bit RGB Transform

Great question—this is a common pain point when trying to bridge lossless compression with the proven redundancy reduction of Y'CbCr. Your observations are spot-on: the compression advantage of lossy Y'CbCr comes directly from its ability to strip spatial redundancy via RGB mixing, while most reversible transforms either require extra bits (like ORCT or YCoCg-R) or produce chroma components too dissimilar to CbCr to match that compression ratio. Let’s tackle your core needs:


1. Reversible Transforms Approximating Y'CbCr

Yes, there are integer-based reversible transforms that closely mimic Y'CbCr’s component distribution, requiring no extra bits (staying strictly 8-bit input → 8-bit output) while enabling lossless round-trip conversion. Here are the most relevant options:

Integer Y'CbCr (iYCC)

Adobe’s iYCC is a standardized reversible transform designed to align closely with JPEG’s Y'CbCr, while using only integer arithmetic to avoid rounding loss. It uses coefficients nearly identical to JPEG’s, adjusted for exact reversibility:

// Forward transform (RGB → iYCC)
Y' = (66 * R + 129 * G + 25 * B + 128) >> 8
Cb = (-38 * R - 74 * G + 112 * B + 128) >> 8 + 128
Cr = (112 * R - 94 * G - 18 * B + 128) >> 8 + 128

// Inverse transform (iYCC → RGB)
R = Y' + (91 * Cr - 128) >> 8
G = Y' - (22 * Cb + 45 * Cr - 128) >> 8
B = Y' + (112 * Cb - 128) >> 8

The key here is the +128 offset before shifting, which ensures that rounding errors are eliminated via exact integer division with bias. The chroma components (Cb/Cr) have nearly identical spatial redundancy to JPEG’s Y'CbCr, making them ideal for lossless compression tools like entropy coders.

Reversible YDbDr Variant

YDbDr (used in PAL video) is mathematically similar to Y'CbCr, and you can adapt it to a reversible 8-bit transform with integer coefficients. Its chroma components (Db/Db) have spatial variance comparable to Cb/Cr, so compression ratios will be on par with iYCC. The integer version uses biased shifts to maintain reversibility without extra bits.

Custom Tuned Integer Transforms

If you need even closer alignment to JPEG’s Y'CbCr, you can tune integer coefficients to match the floating-point Y'CbCr formula exactly, while using the least significant bit (LSB) of one component to store any residual from integer division. For example:

  • During forward transform, compute the exact floating-point Cb/Cr value, then store the integer part in the 8-bit component and the fractional remainder in the LSB of Y' (since Y' has higher perceptual importance, the tiny LSB change won’t affect compression).
  • During inverse transform, extract the remainder from Y'’s LSB to reconstruct the exact original RGB values.
    This keeps all three components 8-bit, maintains near-identical chroma redundancy to Y'CbCr, and is fully reversible.

2. Connection to Your Reference Issues

Your question directly ties to two well-discussed topics in image processing:

  • Lossless RGB to Y'CbCr transformation: The core challenge here is eliminating the rounding error inherent in converting between floating-point Y'CbCr and 8-bit integers. The solutions above address this by using biased integer arithmetic or residual storage in LSBs, avoiding the need for extra bits while preserving reversibility.
  • JPEG: YCrCb <-> RGB conversion precision: JPEG’s standard conversion is lossy because it discards fractional values during rounding. Reversible approximations like iYCC retain the same component structure but use exact integer operations, so you get the spatial redundancy reduction of Y'CbCr without the loss—critical for your lossless compression goal.

3. Meeting Your 8-bit Reversible Requirement

All the transforms above satisfy your need to convert three 8-bit RGB integers to three 8-bit "Y'CbCr-like" integers, with chroma components having lower spatial variance than RGB. The iYCC standard is particularly well-suited, as it’s widely documented, aligns closely with JPEG’s Y'CbCr, and requires no extra storage beyond the three 8-bit components.

内容的提问来源于stack exchange,提问作者Asif Ali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:38:11