Jpeg 图像压缩:量化问题

发布于 2025-01-08 16:58:12 字数 938 浏览 4 评论 0原文

将原始图像编码为 jpeg 图像时,8x8 数据单元会进行电平移位、使用 2-D DCT 进行变换、量化和霍夫曼编码。

我首先执行了行 DCT,然后执行了列 DCT,并将结果四舍五入为最接近的整数。我将此块发送到量化模块。在量化时,我使用了以下 Q 表。这些表是 IJG 针对品质因数 99 推荐的。

Luma Tables

1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 2 2 1
1 1 1 1 1 2 2 2
1 1 1 1 2 2 2 2
1 1 2 2 2 2 2 2
1 2 2 2 2 2 2 2

Chroma Tables

1 1 1 1 2 2 2 2
1 1 1 1 2 2 2 2
1 1 1 2 2 2 2 2
1 1 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2

在量化期间除以“2”时,我将结果舍入到远离零的位置。 示例:11/2 = 6。因此,在解码时的去量化过程中,每个奇数都会添加 +1 的误差。

在另一个设置中,我改变了我的舍入技术。在这里,我将结果四舍五入为零。示例:11/2 = 5。因此,在解码时的去量化过程中,每个奇数都会添加-1 的误差。

在第二种情况下,我得到的文件大小非常小(768x512 图像几乎减少了 100 kb)并且 PSNR 更高。我能够通过说所有在量化为 2 时为“1”的 AC 系数现在将变为 0 而不是 1 来解释较小的文件大小。因此,RLE 使文件大小更小。但我无法解释为什么编码图像质量不断提高。它增加了 2-3 dB,并且我测试的所有图像都发生了这种情况。

我的论点是,因为 DCT 基本上是 A * DCTmatrix,两边的相等误差应该产生相等的损失。但这里的情况并非如此。

While encoding a raw image to a jpeg image, a 8x8 data unit is level shifted, transformed using a 2-D DCT, quantized and Huffman encoded.

I have first performed the Row DCT and then the column DCT and i have rounded the result to the nearest integer. I sent this block to quantization module. While quantizing i have used the following Q Tables. These tables are recommended by IJG for quality factor of 99.

Luma Tables

1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 2 2 1
1 1 1 1 1 2 2 2
1 1 1 1 2 2 2 2
1 1 2 2 2 2 2 2
1 2 2 2 2 2 2 2

Chroma Tables

1 1 1 1 2 2 2 2
1 1 1 1 2 2 2 2
1 1 1 2 2 2 2 2
1 1 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2

During quantization while dividing by '2' i have rounded the result away from zero.
Example: 11/2 = 6. Hence an error of +1 will be added to every odd number during de-quantization while decoding.

In another set up i have changed my rounding technique. Here i am rounding the result towards zero. Example: 11/2 = 5. Hence an error of -1 will be added to every odd number during de-quantization while decoding.

In the second case i am getting very less file size (less by almost 100 kb for a 768x512 image) and more PSNR. I was able to explain the less file size by saying that all the AC coefficients which are '1' when quantized by 2 will now become 0 instead of 1. Hence RLE makes the file size lesser. But i am unable to explain why the encoding image quality is increasing. It is increasing by a factor of 2-3 dB and it happening for all the images i tested.

My argument is as the DCT is basically A * DCTmatrix equal error on either side should yield equal loss. But this is not the case here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文