实验三图像压缩编码技术_第1页
实验三图像压缩编码技术_第2页
实验三图像压缩编码技术_第3页
实验三图像压缩编码技术_第4页
实验三图像压缩编码技术_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、太原理工大学现代科技学院数字图像处理课程实验报告专业班级测控 14-4学号 2021101874姓名杨东倡指导教师刘帆实验名称实验三、图像压缩编码技术同组人专业班级测控 14-414-4 姓名杨东倡学号 20211018742021101874 成绩实验三、图像压缩编码技术一、实验目的1 1、理解有损压缩和无损压缩的概念;2 2、理解图像压缩的主要原那么和目的;3 3、了解几种常用的图像压缩编码方式;4 4、利用 MATLABMATLAB 程序进行图像压缩编码.二、实验原理1 1、图像压缩原理图像压缩主要目的是为了节省存储空间,增加传输速度.图像压缩的理想标准是信息丧失最少,压缩比例最大.不损

2、失图像质量的压缩称为无损压缩,无损压缩不可能到达很高的压缩比; 损失图像质量的压缩称为有损压缩,高的压缩比是以牺牲图像质量为代价的.压缩的实现方法是对图像重新进行编码,希望用更少的数据表示图像.信息的冗余量有许多种,如空间冗余,时间冗余,结构冗余,知识冗余,视觉冗余等,数据压缩实质上是减少这些冗余量.高效编码的主要方法是尽可能去除图像中的冗余成分,从而以最小的码元包含最大的图像信息.编码压缩方法有许多种,从不同的角度出发有不同的分类方法,从信息论角度出发可分为两大类.(1)(1)冗余度压缩方法,也称无损压缩、信息保持编码或嫡编码.具体说就是解码图像和压缩编码前的图像严格相同,没有失真,从数学上

3、讲是一种可逆运算.(2)(2)信息量压缩方法,也称有损压缩、失真度编码或烟压缩编码.也就是说解码图像和原始图像是有差异的,允许有一定的失真.应用在多媒体中的图像压缩编码方法,从压缩编码算法原理上可以分为以下 3 3 类:(1)(1)无损压缩编码种类哈夫曼(HuffmanHuffman) )编码,算术编码,行程(RLRL 日编码,LempelzevLempelzev 编码.(2)(2)有损压缩编码种类预测编码,DPCM,DPCM,运动补偿;频率域方法:正交变换编码(如 DCT),DCT),子带编码;空间域方法:统计分块编码;模型方法:分形编码,模型基编码;基于重要性:滤波,子采样,比特分配,向量

4、量化;(3)(3)混合编码.有 JBIGH.261,JPEGMPEGJBIGH.261,JPEGMPEG 等技术标准.本实验主要利用 MATLABMATLAB 程序进行赫夫曼(HuffmanHuffman) )编码和行程编码(RunLengthEncodingRunLengthEncoding, ,RLERLE.三、实验内容1 1、实现根本 JPEGJPEG 勺压缩和编码分三个步骤:(1)(1)首先通过 DCTDCT 变换去除数据冗余;(2)(2)使用量化表对 DCTDCT 系数进行量化;(3)(3)对量化后的系数进行 HuffmanHuffman 编码.四、实验步骤1 1 翻开计算机,启动

5、MATLABMATLAB 程序;2 2 选择一幅图像,并进行赫夫曼和行程编码压缩处理;3 3 将原图像在 PhotoshopPhotoshop 软件中翻开,分别以不同的位图文件格式进行“另保存,比拟它们的数据量.4 4 记录和整理实验报告Untitled,mclearloadwoman;%X=imread(girl.bmp,bmp);data=uint8(X);zipped,info=huffencode(data);unzipped=huffdecode(zipped,info,data);subplot(121);imshow(data);subplot(122);imshow(unzip

6、ped);erms=compare(data(:),unzipped(:)cr=info.ratiowhosdataunzippedzippedhuffencode.mfunctionzipped,info=huffencode(vector)ifisa(vector,uint8)error(inputargumentmustbeauint8vector);endm,n=size(vector);vector=vector(:);f=frequency(vector);symbols=find(f=0);f=f(symbols);f,sortindex=sort(f);symbols=symb

7、ols(sortindex);len=length(symbols);symbols_index=num2cell(1:len);codeword_tmp=cell(len,1);whilelength(f)1index1=symbols_index1;index2=symbols_index2;codeword_tmp(index1)=addnode(codeword_tmp(index1),uint8(0);codeword_tmp(index2)=addnode(codeword_tmp(index2),uint8(1);f=sum(f(1:2)f(3:end);symbols_inde

8、x=index1,index2symbols_index(3:end);f,sortindex=sort(f);symbols_index=symbols_index(sortindex);endcodeword=cell(256,1);codeword(symbols)=codeword_tmp;len=0;forindex=1:length(vector)len=len+length(codeworddouble(vector(index)+1);endstring=repmat(uint8(0),1,len);pointer=1;forindex=1:length(vector)code

9、=codeworddouble(vector(index)+1;len=length(code);string(pointer+(0:len-1)=code;pointer=pointer+len;endlen=length(string);pad=8-mod(len,8);ifpad0string=stringuint8(zeros(1,pad);endcodeword=codeword(symbols);codelen=zeros(size(codeword);weights=2.A(0:23);maxcodelen=0;forindex=1:length(codeword)len=len

10、gth(codewordindex);iflenmaxcodelenmaxcodelen=len;endiflen0code=sum(weights(codewordindex=1);code=bitset(code,len+1);codewordindex=code;codelen(index)=len;endendcodeword=codeword:;cols=length(string)/8;string=reshape(string,8,cols);weights=2.A(0:7);zipped=uint8(weights*double(string);huffcodes=sparse

11、(1,1);forindex=1:nnz(codeword)%length(codeword)%numel(codeword)huffcodes(codeword(index),1)=symbols(index);endinfo.pad=pad;info.huffcodes=huffcodes;info.ratio=cols./length(vector);info.length=length(vector);info.maxcodelen=maxcodelen;info.rows=m;info.cols=n;huffdecode.mfunctionvector=huffdecode(zipp

12、ed,info,image)ifisa(zipped,uint8)error(inputargumentmustbeauint8vector);endlen=length(zipped);string=repmat(uint8(0),1,len.*8);bitindex=1:8;forindex=1:lenstring(bitindex+8.*(index-1)=uint8(bitget(zipped(index),bitindex);endstring=logical(string(:);len=length(string);string(len-info.pad+1):end)=;len=

13、length(string);weights=2.A(0:51);vector=repmat(uint8(0),1,info.length);vectorindex=1;codeindex=1;code=0;forindex=1:lencode=bitset(code,codeindex,string(index);codeindex=codeindex+1;byte=decode(bitset(code,codeindex),info);ifbyte0vector(vectorindex)=byte-1;codeindex=1;code=0;vectorindex=vectorindex+1

14、;endendvector=reshape(vector,info.rows,info.cols);addnode,nnfunctioncodeword_new=addnode(codeword_old,item)codeword_new=cell(size(codeword_old);forindex=1:length(codeword_old)codeword_newindex=itemcodeword_oldindex;endfrequriey.iTifunctionf=frequency(vector)ifisa(vector,uint8)error(inputargumentmust

15、beauint8vector);endf=repmat(0,1,256);len=length(vector);forindex=0:255f(index+1)=sum(vector=uint8(index);endf=f./len;decofunctionbyte=decode(code,info)byte=info.huffcodes(code);comparemfunctionerms=compare(f1,f2)e=double(f1)-doublef2);m,n=size(e);erms=sqrt(sum(e(:).A2)/(m*n);iferms=0emax=max(abs(e(:

16、);h,x=hist(e(:);iflength(h)=1figure(4)bar(x,h,k);e=mat2gray(e,-emax,emax);figure(5);imshow(e);endendWindow:UntitledQcr=Naaac名工zuClass65536jlntBunzipped2SK2565536u-srpped41226umtfiFigure1FileEditViewInserfT口口化DesktopWfndowHelp口君命霎口Untitled.wKRLEncode.mXRLEdecode.mXcompare.m乂Untitled5*X1-clearall;I=iz

17、nxead(1C:UsexsaDesktopbarbarabmp1(zippedrinfowRLEncode(I);unziFped=RLEde|code(zipped,info)subplot(121);iiLShow(I);6-subplot(122);inLshow(unzipped);7-erms=conipaxe(1(:)runzipped(:)8 -cr-info.ratio9 -whosIunzippedzipped%w1nL*CLipli4auuiEf-frsrIf-?11*1IB匚口工 D-,-remiisIslelluLipintoublclEiplE.,Zi:l、;1=三

18、71p4 壮:LZ=UR, ,PP-Wnacu 二 A 二 rfidIIMGw 皿 6JgiUnrtltld.nnRLEntQde.mxRLEdcodmXcompare,inXUntitled5*乂干上ft匕七工亡工LWLHPdr=RLEneeds(vecei:)la,n=aise(vector);vectrint.9veetor(!);L=Length(vector);G=vecccr(1);亡(工/工二心;曰1工/2)三口;U1=Lforj=l!Liff(sector(j)CH11eCtlr2)=dcutole(e+1;else1-1+Le(t&2)=Lend!.zrpp&d=e;info

19、,zcw5=in;info colsn;21in,r)=3izee);lno.racic=in*n/info.rcwsinfo cols;If|i(bomEeE:立%iiiTLarEEflMTBL 马内七.tQ_ja械-jCwTfcrwNewLMiSwdfrti.bwriZ 里国.f-I1y.MWtl 后.U1iMWUfftjMgptfUmried.ini1xHLEfKiDdejm/RLEdecadejm 司 muarNfiRL-mrcrfSIi&E-lLX七HkiWWrtRtfi艮alHU无力|_yJM*aiWgHuhaeccion=reprrc(zip(1,1),1,dotlble(zip

20、(1,2);unzipped=unzippedsection;endLunEipped=reshape(unzlpeC/info*rows,iuto.cols)Untitled,m招RLEnccde.mxRLEdecodem匚ompoynn汽Untitled5*1fimcuionexrLS=cartpaze(fl,12)2-e=doutole|(fl)-double(X2);3-Imrn=size(e;4emL3=sqrc(sum(e(:i.*2,(n*n);Untitled.rnxRLEncode.m肖RLEdecode.m*compare.rmMUrrtitled5*试试1Qde1工工p.口匚Jfunctionuxmpg曰EipintS(zip);ltrn=3125(2ip)Junsipped=GXomrr-andwindovuXwU1二QHO2XT3,7h一-1X-Tan口JxxxuoXJr/149149149162117149117117117877-5143117了414S16213C16213C1301231177专11713687135143149105117ISO117149IDS8714911774117149130371491621491D=162117117IDSB7149149105130

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论