Jpeg编码技术
我听说Jpeg使用霍夫曼编码。什么是霍夫曼码?
I heard that Jpeg uses Hufman code. What is Huffman code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我听说Jpeg使用霍夫曼编码。什么是霍夫曼码?
I heard that Jpeg uses Hufman code. What is Huffman code?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
只是为了完成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:
you will have a matrix with DCT coefficients, showing frequency information, concentrating most information in the left superior corner:
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.
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.
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.
霍夫曼编码是一种采用符号(例如字节、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