实验三图像压缩编码技术Word文档下载推荐.docx

上传人:b****2 文档编号:3326664 上传时间:2023-05-01 格式:DOCX 页数:16 大小:685.62KB
下载 相关 举报
实验三图像压缩编码技术Word文档下载推荐.docx_第1页
第1页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第2页
第2页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第3页
第3页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第4页
第4页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第5页
第5页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第6页
第6页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第7页
第7页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第8页
第8页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第9页
第9页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第10页
第10页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第11页
第11页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第12页
第12页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第13页
第13页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第14页
第14页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第15页
第15页 / 共16页
实验三图像压缩编码技术Word文档下载推荐.docx_第16页
第16页 / 共16页
亲,该文档总共16页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

实验三图像压缩编码技术Word文档下载推荐.docx

《实验三图像压缩编码技术Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《实验三图像压缩编码技术Word文档下载推荐.docx(16页珍藏版)》请在冰点文库上搜索。

实验三图像压缩编码技术Word文档下载推荐.docx

损失图像质量的压缩称为有损压缩,高的压缩比是以牺牲图像质量为代价的。

压缩的实现方法是对图像重新进行编码,希望用更少的数据表示图像。

信息的冗余量有许多种,如空间冗余,时间冗余,结构冗余,知识冗余,视觉冗余等,数据压缩实质上是减少这些冗余量。

高效编码的主要方法是尽可能去除图像中的冗余成分,从而以最小的码元包含最大的图像信息。

编码压缩方法有许多种,从不同的角度出发有不同的分类方法,从信息论角度出发可分为两大类。

(1)冗余度压缩方法,也称无损压缩、信息保持编码或熵编码。

具体说就是解码图像和压缩编码前的图像严格相同,没有失真,从数学上讲是一种可逆运算。

(2)信息量压缩方法,也称有损压缩、失真度编码或烟压缩编码。

也就是说解码图像和原始图像是有差别的,允许有一定的失真。

应用在多媒体中的图像压缩编码方法,从压缩编码算法原理上可以分为以下3类:

(1)无损压缩编码种类

哈夫曼(Huffman)编码,算术编码,行程(RLE)编码,Lempelzev编码。

(2)有损压缩编码种类

预测编码,DPCM,运动补偿;

频率域方法:

正交变换编码(如DCT),子带编码;

空间域方法:

统计分块编码;

模型方法:

分形编码,模型基编码;

基于重要性:

滤波,子采样,比特分配,向量量化;

(3)混合编码。

有JBIG,H.261,JPEG,MPEG等技术标准。

本实验主要利用MATLAB程序进行赫夫曼(Huffman)编码和行程编码(RunLengthEncoding,RLE)。

三、实验内容

1、实现基本JPEG的压缩和编码分三个步骤:

(1)首先通过DCT变换去除数据冗余;

(2)使用量化表对DCT系数进行量化;

(3)对量化后的系数进行Huffman编码。

四、实验步骤

1打开计算机,启动MATLAB程序;

2选择一幅图像,并进行赫夫曼和行程编码压缩处理;

3将原图像在Photoshop软件中打开,分别以不同的位图文件格式进行“另保存”,比较它们的数据量。

4记录和整理实验报告

clear

loadwoman;

%X=imread('

girl.bmp'

'

bmp'

);

data=uint8(X);

[zipped,info]=huffencode(data);

unzipped=huffdecode(zipped,info,data);

subplot(121);

imshow(data);

subplot(122);

imshow(unzipped);

erms=compare(data(:

),unzipped(:

))

cr=info.ratio

whosdataunzippedzipped

function[zipped,info]=huffencode(vector)

if~isa(vector,'

uint8'

error('

inputargumentmustbeauint8vector'

end

[m,n]=size(vector);

vector=vector(:

)'

;

f=frequency(vector);

symbols=find(f~=0);

f=f(symbols);

[f,sortindex]=sort(f);

symbols=symbols(sortindex);

len=length(symbols);

symbols_index=num2cell(1:

len);

codeword_tmp=cell(len,1);

whilelength(f)>

1

index1=symbols_index{1};

index2=symbols_index{2};

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_index=[{[index1,index2]}symbols_index(3:

symbols_index=symbols_index(sortindex);

codeword=cell(256,1);

codeword(symbols)=codeword_tmp;

len=0;

forindex=1:

length(vector)

len=len+length(codeword{double(vector(index))+1});

string=repmat(uint8(0),1,len);

pointer=1;

length(vector)

code=codeword{double(vector(index))+1};

len=length(code);

string(pointer+(0:

len-1))=code;

pointer=pointer+len;

len=length(string);

pad=8-mod(len,8);

ifpad>

string=[stringuint8(zeros(1,pad))];

codeword=codeword(symbols);

codelen=zeros(size(codeword));

weights=2.^(0:

23);

maxcodelen=0;

length(codeword)

len=length(codeword{index});

iflen>

maxcodelen

maxcodelen=len;

code=sum(weights(codeword{index}==1));

code=bitset(code,len+1);

codeword{index}=code;

codelen(index)=len;

codeword=[codeword{:

}];

cols=length(string)/8;

string=reshape(string,8,cols);

7);

zipped=uint8(weights*double(string));

huffcodes=sparse(1,1);

nnz(codeword)%length(codeword)%numel(codeword)

huffcodes(codeword(index),1)=symbols(index);

info.pad=pad;

info.huffcodes=huffcodes;

info.ratio=cols./length(vector);

info.length=length(vector);

info.maxcodelen=maxcodelen;

info.rows=m;

info.cols=n;

functionvector=huffdecode(zipped,info,image)

if~isa(zipped,'

len=length(zipped);

string=repmat(uint8(0),1,len.*8);

bitindex=1:

8;

len

string(bitindex+8.*(index-1))=uint8(bitget(zipped(index),bitindex));

string=logical(string(:

string((len-info.pad+1):

end)=[];

51);

vector=repmat(uint8(0),1,info.length);

vectorindex=1;

codeindex=1;

code=0;

code=bitset(code,codeindex,string(index));

codeindex=codeindex+1;

byte=decode(bitset(code,codeindex),info);

ifbyte>

vector(vectorindex)=byte-1;

vectorindex=vectorindex+1;

vector=reshape(vector,info.rows,info.cols);

functioncodeword_new=addnode(codeword_old,item)

codeword_new=cell(size(codeword_old));

length(codeword_old)

codeword_new{index}=[item

codeword_old{index}];

functionf=frequency(vector)

if~isa(vector,'

f=repmat(0,1,256);

len=length(vector);

forindex=0:

255

f(index+1)=sum(vector==uint8(index));

f=f./len;

functionbyte=decode(code,info)

byte=info.huffcodes(code);

functionerms=compare(f1,f2)

e=double(f1)-double(f2);

[m,n]=size(e);

erms=sqrt(sum(e(:

).^2)/(m*n));

iferms~=0

emax=max(abs(e(:

)));

[h,x]=hist(e(:

));

iflength(h)>

=1

figure(4)

bar(x,h,'

k'

e=mat2gray(e,[-emax,emax]);

figure(5);

imshow(e);

end

五、实验仪器

1计算机;

2MATLAB、Photoshop等程序;

3移动式存储器(软盘、U盘等)。

4记录用的笔、纸。

六、实验报告内容

1叙述实验过程;

2提交实验的原始图像和结果图像。

七、思考题

1.图像中哪些信息是主要的,哪些信息是次要的?

 

答;

频域的低频分量影响更大一些,而高频分量相对次要。

2.简述赫夫曼编码和行程编码的原理。

答:

赫夫曼编码:

先统计数据中各字符出现的概率,再按字符出现频率高低的顺序分别

赋以由短到长的代码,从而保证文件整体的大部分字符是由较短的编码所构成。

行程编码;

又称行程长度编码(Run 

Length 

Encoding, 

RLE), 

是一种熵编码,其编码原理是将具有相同值的连续串用其串长和一个代表值来代替, 

该连续串就称为行程,串长称为行程长度。

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2