课程要求
Assignment IV Transform + Quantization + Entropy Coding
Input: an intra-frame or a residue picture after motion compensation.
Task: Code the input picture into a bitstream and decode the picture from the generated bitstream.
Specifications: Implement a transform-based codec, consisting transform, quantization, and entropy coding. The block size can be 8x8, 16x16, or other reasonable sizes. As in most existing image/video codecs, you can use 2D DCT. A simple uniform quantizer could be used for verification purpose. For the entropy coding, you can use either Huffman coding or arithmetic coding
README
运行main函数,注意main函数用到了下面的Normalize函数
指定待处理的图片,依次对图片进行一下变换:
一、灰度化
二、8 * 8 DCT变换(这一步r)如果加上一个掩模可以去除图片中人眼不敏感的高频分量,从而进一步压缩图片
三、量化处理(采用JPEG亮度量化表,将DCT举证除以量化码表),由于量化后有取整操作,因此是有损压缩图片
四、Huffman编码,编码得到的比特流序列比原序列更加短小,进一步提高传输效率
五、发送方比特流序列传输(将上一步得到的比特流进行传输)
%中间对比了直接传输图片的比特流长度和经过压缩变换得到的比特流长度
六、接收方接收比特流序列
七、解码,是Huffman编码的逆过程,得到量化后的序列
八、反量化处理,是第三步的逆过程,将量化后的矩阵乘以量化码表
九、反DCT变换得到图片
main函数:
1 clc;clear; 2 3 %采用JPEG亮度量化表 4 Q =[16 11 10 16 24 40 51 61 5 12 12 14 19 26 58 60 55 6 14 13 16 24