www.pudn.com > Upload_EZW128.zip > ezw_decode_128.m


%clear 
clc 
%load 
format long 
%[ar br cr dr]=wfilters('db4'); 
 
load indices 
load lena %kitten 
%x=kitten; 
orig=x(50:50+127,50:50+127); 
clear x 
enc=symlen; 
%T=2^round(log2(max(max(abs(mat))))); 
T=512;%T/2 
xm=mapping_128; 
xm=xm(:); 
x=xm; 
dec(128*128)=0; 
kk=1; 
ii=1; 
c=enc(ii); 
root_indices=[0]; 
sig_ele=[0]; 
req=[]; 
aaa=0; 
while T>=2 
    %-----------------------------------------------------------------------------     
% Check Dominant pass first  
root_indices=[0]; 
sig_ele=[0]; 
kk=1; 
while (c~='0' & c~='1' & ii512 & kk<1025 
                temp=indices(indices(kk,1:end),1:end); % Mistake , Every where i wrote ii instead of kk 
                root_indices=[root_indices indices(kk,1:end)  (temp(:))']; 
                kk=kk+1; 
            elseif kk>1024 & kk<4097 
                root_indices=[root_indices indices(kk,1:end)]; 
                kk=kk+1; 
            end 
        end 
        ii=ii+1; 
    else kk=kk+1;    % Because of this i faced some problem, i forgot to do it 
    end 
end 
req=[req sig_ele(2:end)]; % To remove 0 , see intialization, not null, b'cos it gives warnings 
% Req contains all the coefficient indices in order which are found significant 
if(ii0),s=1; 
        else s=0; 
        end 
        if enc(ii-1)=='1' 
            dec(req(rr))=abs(dec(req(rr)))+T/4; % ??? 
        elseif enc(ii-1)=='0' 
            dec(req(rr))=abs(dec(req(rr)))-T/4; % ??? 
        end 
        if s==0,dec(req(rr))=-dec(req(rr));end 
        ii=ii+1; 
    end 
end 
ii=ii-1; 
disp('-------------------------------------------------------'); 
T 
rec=round(reshape(dec(xm(:)),128,128)); 
%xr=itransform_128(rec); 
xr=synth2d(rec,3,3); 
figure,imshow(mat2gray(xr)) 
PSNR(xr,orig),ii 
aaa=aaa+length(sig_ele) 
disp('-------------------------------------------------------'); 
T=T/2; 
drawnow 
c=enc(ii); 
end