Jpeg编码技术

发布于 2024-10-16 06:35:14 字数 30 浏览 4 评论 0原文

我听说Jpeg使用霍夫曼编码。什么是霍夫曼码?

I heard that Jpeg uses Hufman code. What is Huffman code?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

哆兒滾 2024-10-23 06:35:14

只是为了完成david99world给出的答案:

霍夫曼编码只是jpeg压缩的最后一步。重要的压缩来自应用于 DCT 的量化矩阵。这是什么?嗯,DCT变换只是一种通过频率来显示图像信息的方法。 而不是像这样具有像素值的矩阵:

在此处输入图像描述

您将拥有一个带有 DCT 系数的矩阵,显示频率, 信息,将大部分信息集中在左上角:

在此处输入图像描述

现在您已经有了 DCT 系数,它是真正的压缩步骤,即将所有值除以基于人眼视觉的量化矩阵。该矩阵将使包含与人眼不相关的信息的系数为零,并使重要的系数几乎相同。

在此处输入图像描述

为什么此步骤对于压缩很重要?因为现在您有很多零,霍夫曼编码会将大量零分组为小代码字,因此您可以节省存储空间。

在此处输入图像描述

您可以尝试在 Matlab 中编写整个算法,您会更好地理解它。请注意,如果多次应用 Q 矩阵,您将获得更多压缩(更多零),但图像质量也会降低。

我希望这能让你更清楚。

Just to complete the answer given by david99world:

Huffman coding is just a final step in jpeg compression. The important compression comes from the Quantization matrix applied to the DCT. What is this? Well, the DCT transformation is just a way to show image information by frequencies. Instead of having a matrix with pixel values like this:

enter image description here

you will have a matrix with DCT coefficients, showing frequency information, concentrating most information in the left superior corner:

enter image description here

Now that you have the DCT coefficients here it comes the real compression step, which is dividing all the values by a Quantization Matrix based on human eye vision. This Matrix will make zero those coefficients containing information not relevant for human eye and will let almost the same the important ones.

enter image description here

Why is this step important for compression? Because now that you have a lot of zeros, Huffman coding will group large amounts of zeros in small code-words, so you are saving storage memory.

enter image description here

You can try to program in Matlab the whole algorithm and you will understand it better. Note that if you apply the Q matrix several times, you will have more compression (more zeros), but also a lower quality image.

I hope this make things clearer for you.

记忆で 2024-10-23 06:35:14

霍夫曼编码是一种采用符号(例如字节、DCT系数等)并使用根据统计概率分配的可变长度代码对其进行编码的方法。经常使用的符号将用仅占用几个比特的代码进行编码,而很少使用的符号则由需要更多比特来编码的符号来表示。

JPEG 文件最多包含 4 个霍夫曼表,这些表定义这些可变长度代码(占用 1 到 16 位)和代码值(8 位字节)之间的映射。创建这些表通常涉及计算每个符号(DCT 码字)在图像中出现的频率,并相应地分配位串。但是,大多数 JPEG 编码器仅使用 JPEG 标准中提供的霍夫曼表。一些编码器允许优化这些表,这意味着创建一个最佳二叉树,从而可以生成更有效的霍夫曼表。

看看http://www.cs.duke.edu/csed/poop/huff/info / 以获得更深入的解释

Huffman coding is a method that takes symbols (e.g. bytes, DCT coefficients, etc.) and encodes them with variable length codes that are assigned according to statistical probabilities. A frequently-used symbol will be encoded with a code that takes up only a couple bits, while symbols that are rarely used are represented by symbols that take more bits to encode.

A JPEG file contains up to 4 huffman tables that define the mapping between these variable-length codes (which take between 1 and 16 bits) and the code values (which is an 8-bit byte). Creating these tables generally involves counting how frequently each symbol (DCT code word) appears in an image, and allocating the bit strings accordingly. But, most JPEG encoders simply use the huffman tables presented in the JPEG standard. Some encoders allow one to optimize these tables, which means that an optimal binary tree is created which allows a more efficient huffman table to be generated.

Have a look at http://www.cs.duke.edu/csed/poop/huff/info/ for a much deeper explanation

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文