📄 ezw_decode.m
字号:
%*********************************%
%*********EZW decoder*************%
%*********************************%
function ezw_decode_x=ezw_decode(X,LEVEL,DD,L1,SS,L2)
Y0=max(X);
Y1=max(Y0); %找到像素中最大值
%设最初门限制
for i=0:20;
if 2^i<=Y1 & 2^i>0.5*Y1;
threshold=2^i;
initialthreshold=threshold;
laststeplevel=i+1;
break;
end;
end;
global N;
[m,n]=size(N); % the size of initial image, m is the pixels of initial image
XX=zeros(sqrt(m)); % initialize the reconstructured image to zero;
threshold=initialthreshold; % initial theshold ;
sublist=[]; % sublist is the new position matrix for all significant coefficients 'p' and 'n';
f=min(laststeplevel,LEVEL);
for level=1:f,
RR=zeros(size(XX));
b=L1(level+1);
% dominant pass
i=1; j=1;
while i<=m;
if j>b; % b is the length of dominant pass vector
break;
end
if RR(N(i,1),N(i,2))==1;
i=i+1;
else
if DD(j+sum(L1(1:level)))=='p';
XX(N(i,1),N(i,2))=threshold;
RR(N(i,1),N(i,2))=1;
sublist=[sublist;N(i,1),N(i,2)];
end
if DD(j+sum(L1(1:level)))=='n';
XX(N(i,1),N(i,2))=-threshold;
RR(N(i,1),N(i,2))=1;
sublist=[sublist;N(i,1),N(i,2)];
end
if DD(j+sum(L1(1:level)))=='z';
RR(N(i,1),N(i,2))=1;
end
if DD(j+sum(L1(1:level)))=='t';
RR(N(i,1),N(i,2))=1;
RR=checkchildren(i,RR);% all zerotree's descendants are set to 1.
end
i=i+1;j=j+1;
end
end
% subordinate pass
[xx,yy]=size(sublist);
threshold=threshold/2;
for i=1:xx;
if level==laststeplevel |threshold==0.5;
break;
end
if SS(i+sum(L2(1:level)))==1;
if XX(sublist(i,1),sublist(i,2))>0;
XX(sublist(i,1),sublist(i,2))= XX(sublist(i,1),sublist(i,2))+ threshold;
else
XX(sublist(i,1),sublist(i,2))= XX(sublist(i,1),sublist(i,2))-threshold;
end
end
end
end
ezw_decode_x=XX;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -