dwt_lifting1d.m

来自「小波压缩编码平台软件包」· M 代码 · 共 44 行

M
44
字号
function [a,d] = dwt_lifting1D(x,wvf)
%[a,d] = dwt_lifting1D(x,wvf)
%Version: 1.10, Date: 2006/11/01, author: Nikola Sprljan
%DWT of a 1D signal in lifting implementation
%
%Input: 
% x - signal to be transformed
% wvf - wavelet identification string, or wavelet data structure
%     
%Output: 
% a - approximation (low-pass) signal
% d - detail (high-pass) signal
%
%Example:
% [a,d] = dwt_lifting1D(x,wvf);
% [a,d] = dwt_lifting1D(x,'CDF_9x7');

if ischar(wvf)
    wvf = load_wavelet(wvf);
end;    
s = wvf.lift_coeff;
K = wvf.lift_norm;
cn = wvf.lift_cnct;

%xe - for 1-pixel extended signal
xe = zeros(1,length(x)+2);
xe(2:end-1) = x;
for i=1:length(s)    
    xe(1) = xe(3); %extension on the left
    xe(end) = xe(end-2); %extension on the right
    start = rem(i,2); %determines if it is prediction or update step, 1 - prediction, 0 - update
    lind = 1+start:2:length(xe)-2;
    cind = lind + 1;
    rind = cind + 1;
    if (cn(i,1) == '1') %left connection present
        xe(cind) = xe(cind) + s(i)*xe(lind); %left pixel lifting
    end;
    if (cn(i,2) == '1') %right connection present
        xe(cind) = xe(cind) + s(i)*xe(rind); %right pixel lifting
    end;
end;
%normalisation
a = xe(2:2:end-1) * K(1);
d = xe(3:2:end-1) * K(2);

⌨️ 快捷键说明

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