⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ezw_decode_128.m

📁 这是一种小波变换编码
💻 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' & ii<length(enc)),
    if(sum([root_indices==kk])==0 & sum([find(dec~=0)==kk])==0)
        c=enc(ii);
        if c=='p'
            dec(kk)=mean([T 2*T]);
            sig_ele=[sig_ele kk];
            kk=kk+1;
        elseif c=='n'
            dec(kk)=-1*mean([T 2*T]);
            sig_ele=[sig_ele kk];
            kk=kk+1;
        elseif c=='z'
            %dec(kk)=0;
            kk=kk+1;
        elseif c=='r'
            if kk>512 & 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(ii<length(enc))
    for rr=1:length(req)
        if (dec(req(rr)) >0),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

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -