实验四-dpcm编码
来源:互联网 发布:淘宝产品推广方案 编辑:程序博客网 时间:2024/06/05 17:19
一、实验原理
DPCM编码,是差分预测编码调制的缩写,是典型的预测编码系统。这种方式是用已经过去的抽样值来预测当前的抽样值,对它们的差值进行编码。之所以不用原始样本做预测是因为在解码端无法得到原始样本数据,只能得到存在误差的样本。差值编码可以提高编码频率,这种技术已应用于模拟信号的数字通信之中。
二、实验步骤
三、关键代码分析
1)dpcm函数
void dpcm(unsigned char *srcBuffer,int width,int height,unsigned char *rebuidBuffer,unsigned char *MSEBuffer){ int i,j; char temp1; unsigned char temp2; for(i=0;i<height;i++) { temp1=srcBuffer[i*width]-128;//对第一列用128做预测,预测范围为-128到128 temp2=(temp1+128)/2;//加128提升到0-256再量化 MSEBuffer[i*width]=temp2*2;//反量化 rebuidBuffer[i*width]=MSEBuffer[i*width];//量化误差加上预测值再减128得到预测样本 for(j=1;j<width;j++) { temp1=srcBuffer[i*width+j]-rebuidBuffer[i*width+j-1];//用它右侧的误差样本来做预测 temp2=(temp1+128)/2; MSEBuffer[i*width+j]=temp2*2; rebuidBuffer[i*width+j]=rebuidBuffer[i*width+j-1]+MSEBuffer[i*width+j]-128; } }}
2)将bmp数据做dpcm编码
Readrgb(input,file_h,info_h,rgbDataOut);//从bmp文件中提取rgb数据 //read y unsigned char *srcBuffer=(unsigned char*)malloc(info_h.biWidth*info_h.biHeight); unsigned char *rebuidBuffer=(unsigned char*)malloc(info_h.biWidth*info_h.biHeight); unsigned char *MSEBuffer=(unsigned char*)malloc(info_h.biWidth*info_h.biHeight); if(!(srcBuffer && rebuidBuffer && MSEBuffer)) { printf("malloc ybuffer error!\n"); } RGB2YUV (info_h.biWidth,info_h.biHeight,rgbDataOut,0,srcBuffer);/*将rgb数据转化为yuv*/ dpcm(srcBuffer,info_h.biWidth,info_h.biHeight,rebuidBuffer,MSEBuffer); fwrite(MSEBuffer,sizeof(unsigned char),info_h.biWidth*info_h.biHeight,output);//将误差数据写入输出文件
四、实验结果
1)dpcm输出的重建图像
2)原始图像
3)预测误差图像和原始图像huffman编码比较
4)预测误差图像和原始图像的符号概率分布
五、结论
在dpcm编码之后,信源符号的分布更加集中,huffman编码的效率提高了。
0 0
- 实验四-dpcm编码
- 实验四 DPCM编码
- 实验四 DPCM编码
- 实验四:DPCM编码
- 数据压缩实验四:DPCM编码
- 数据压缩实验四:DPCM编码
- 实验四——DPCM编码
- 【实验五】DPCM编码
- 实验4 DPCM编码
- 【数据压缩】实验四 DPCM
- 数据压缩实验4-DPCM编码
- 数据压缩实验四--dpcm压缩系统
- DPCM编码
- DPCM编码
- 实验四 DPCM 压缩系统的实现和分析
- 数据压缩实验四:DPCM 压缩系统的实现和分析
- 数据压缩实验四 DPCM压缩系统的实现与分析
- 《数据压缩》实验报告四·DPCM编解码
- 一个程序员的所思所想
- Java中 == 和 equalse()
- 第16章 多线程-1
- BeanUtils.copyProperties()使用
- Android UI绘制流程(二)
- 实验四-dpcm编码
- hihoCoder 1066 : 无间道之并查集
- SELECT语句语法格式
- 09 WebGL通过uniform变量修改点的颜色
- 指针与数组
- 有限状态机时序电路设计之检测连续四个0或1的个数
- maven创建java项目
- GitHub上fork别人的项目,并保存同步方法
- Docker学习笔记(一)