嵌入式小波零树编码压缩(2)

2018-12-17 14:14

end end

scNum=scNum+1; end end end

Decodeflag=flagMat; for i=1:row for j=1:col

switch flagMat(i,j) case {'P','N'} flagMat(i,j)='O'; case {'T','X'} flagMat(i,j)='Z'; end end end

嵌入式小波零树(EZW)算法的过程详解和Matlab代码(4)运行示例 收藏

最后,我们以一幅64*64的Lena局部图像来演示EZW算法的编解码效果。

首先给出相关的编解码主程序。

function y=ezw(Im,imDim,codeDim,DecodeDim) global row col [row,col]=size(Im); % ----- Wavedec -----%

DecIm=mywavedec2(Im,imDim); % ----- Select threshold -----% MaxDecIm=max(max(abs(DecIm))); T=zeros(1,codeDim);

T(1)=2^flor(log2(MaxDecIm)); for i=2:codeDim T(i)=T(i-1)/2; end

% ----- EZW coding -----%

[CodeList,LenSubCL,QuantiFlagList,LenSubQFL]=ezwcode(DecIm,T,codeDim); % ----- EZW decoding -----%

DecodeMat=ezwdecode(DecIm,T(1),DecodeDim,CodeList,LenSubCL,QuantiFlagList,LenSubQFL);

% ----- Waverec -----% DecIm(1:row/8,1:col/8) DecodeMat(1:row/8,1:col/8)

RecIm=mywaverec2(DecodeMat,imDim);

function [CodeList,LenSubCL,QuantiFlagList,LenSubQFL]=ezwcode(Mat,threshold,codedim) global row col

scanlist=morton(Mat); flaglist(1:row,1:col)='Z'; imptvalue=[]; imptflag=[];

% ----- Intializing EZW coding output variables -----% CodeList=[]; LenSubCL=[]; QuantiFlagList=[]; LenSubQFL=[];

% ----- Coding loop -----% for d=1:codedim

[imptvalue,imptflag,scancode,scanflag,flaglist]=mainscan(Mat,scanlist,flaglist,i

mptvalue,imptflag,threshold(d));

[quantilist,quantiflag,recvalue,quantifierMat]=assistscan(imptvalue,d,threshold(1));

% Produce code dataflow CodeList=[CodeList,scancode];

LenSubCL=[LenSubCL,length(scancode)]; QuantiFlagList=[QuantiFlagList,quantiflag']; LenSubQFL=[LenSubQFL,length(quantiflag)]; end

function DecodeMat=ezwdecode(Mat,T1,decodeDim,CodeList,LenSubCL,QuantiFlagList,LenSubQFL) global row col recvalue=[]; rIlist=[];

quantiflagOld=[];

scanorder=listorder(row,col,1,1); flagMat(1:row,1:col)='Z';

for level=1:decodeDim

scancode=CodeList(1:LenSubCL(level)); CodeList=CodeList(LenSubCL(level)+1:end); quantiflag=QuantiFlagList(1:LenSubQFL(level));

QuantiFlagList=QuantiFlagList(LenSubQFL(level)+1:end);

DecodeMat=Mat; qrNum=1; scNum=1;

[antiQuantiMat,rIlist,quantiflagOld]=antiquantifier(T1,level,rIlist,quantiflag,quantiflagOld);

[DecodeMat,recvalue,qrNum]=updateRecvalue(DecodeMat,recvalue,qrNum,quantiflag,antiQuantiMat,rIlist);

[DecodeMat,flagMat,recvalue]=decoding(DecodeMat,flagMat,recvalue,antiQuantiMat,quantiflag,rIlist,scanorder,scancode,scNum,qrNum); % if level

% button = questdlg('Need the nest decode processing ?','Decode Level','Yes','No','Yes');

% if button(1)=='N' % break; % end % end end

(1)图像3级分解、5级编码、5级解码下的效果图。

ezw(Im64,3,5,5);

分解矩阵DecIm的部分数据

40.9531 87.2344 94.2188 161.2031 64.3125 40.4063 37.5781 65.6875

110.8281 129.3125 91.5625 164.3750 107.1719 50.5469 34.9688 75.2188

150.7813 134.5156 98.0625 164.9688 121.7344 67.5469 28.0938 77.1250

132.9219 117.7656 91.0938 155.3125 117.0781 53.0781 28.1563 83.3750

119.3281 118.5156 95.1875 137.1719 105.8750 30.3906 33.6094 79.6406

100.8906 102.9375 119.2031 132.8438 71.5000 28.6875 38.5313 75.3281

103.2813 85.3750 102.6250 107.4531 31.3594 28.2656 45.3438 79.7813

98.4844 120.0938 134.8438 73.3281 29.1719 33.6094 50.3906 0781

解码矩阵DecodeMat的对应数据

42 86 94 162 66 42 38 66 110 130 90 166 106 50 34 74 150 134 98 166 122 66 30 78 134 118 90 154 118 54 30 82 118 118 94 138 106 30 34 78 102 102 118 134 70 30 38 74 102 86 102 106 30 30 46 78 98 122 134 74 30 34 50 86

运行效果:

86.


嵌入式小波零树编码压缩(2).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:人防施工单位汇报材料

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: