Sie sind auf Seite 1von 5

66 JIANZHONG WANG

2. 1-D Discrete Wavelet Transform in MATLAB


1-D Discrete Wavelet Transform in MATLAB
The following functions are already in the MATLAB Wavelet Tool-
box. dwt, wavedec, idwt, waverec, upcoef, detcoef, appcoef,
upwlev.

(1) Functions for Wavelet Decomposition.


dwt, wavedec
• dwt
function [a,d] = dwt(x,arg2,arg3)
DWT performs a single-level 1-D wavelet decomposition
with respect to either a particular wavelet (’wname’) or a par-
ticular wavelet filters (Lo D and Hi D) you specify.
Usage
[CA,CD] = dwt(X,’wname’)
computes the approximation coefficients vector CA and de-
tail coefficients vector CD, obtained by wavelet decomposition
of the vector X. ’wname’ is a string containing the wavelet
name.
[CA,CD] = dwt(X,Lo D,Hi D)
computes the wavelet decomposition as above given these
filters as input:
Lo D is the decomposition low-pass filter and Hi D is the
decomposition high-pass filter. Lo D and Hi D must be the
same length.
If lx = length(X) and lf is the length of filters then
length(CA) =length(CD) = FLOOR((lx+lf-1)/2).
• wavedec
function [c,l] = wavedec(x,n,arg3,arg4)
WAVEDEC performs a multi-level 1-D wavelet decomposi-
tion using either a specific wavelet (’wname’) or specific wavelet
decomposition filters.
Usage
[C,L] = wavedec(X,N,’wname’)
returns the wavelet decomposition of the signal X up to
level N, using ’wname’. N must be a strictly positive inte-
ger. The output decomposition structure contains the wavelet
decomposition vector C and the bookkeeping vector L. For
[C,L] = wavedec(X,N,Lo D,Hi D),
Lo D is the decomposition low-pass filter and Hi D is the
decomposition high-pass filter.
The structure of vector C and L is organized as:
C = [appcoef(N), wavecoef(N),...,wavecoef(1)],
2. 1-D DISCRETE WAVELET TRANSFORM IN MATLAB 67

where appcoef(N) is the N-level approximation coefficients


of the wavelet decomposition while wavecoef(J) is the N-level
wavelet coefficients of the wavelet decomposition.
In vector L, L(1)=length of appcoef(N), while L(i)=length
of wavecoef (N-i+2), for i = 2,...,N+1.
Finally, L(N+2) = length(X).
(2) Functions for Wavelet Reconstruction
• idwt
function x = idwt(a,d,arg3,arg4,arg5)
IDWT performs a single-level 1-D wavelet reconstruction
with respect to either a particular wavelet (’wname’) or a par-
ticular wavelet reconstruction filters you specify.
Usage
X = idwt(CA,CD,’wname’)
returns the single-level reconstructed approximation coeffi-
cients vector X based on approximation and detail coefficients
vectors CA and CD, and using the wavelet ’wname’.
X = idwt(CA,CD,Lo R,Hi R)
reconstructs approximation coefficients vector X as above,
using filters you specify:
Lo R is the reconstruction low-pass filter and Hi R is the
reconstruction high-pass filter. Lo R and Hi R must be the
same length.
If la = length(CA) = length(CD) and lf is the length of
the filters, then
length(X) = 2*la-lf+2.
X = idwt(CA,CD,’wname’,L) or
X = idwt(CA,CD,Lo R,Hi R,L)
returns the length-L central portion of the result obtained
using idwt (CA,CD,’wname’). L must be less than 2*la-lf+2.
• waverec
function x = waverec(c,l,arg3,arg4)
WAVEREC
performs a multi-level 1-D wavelet reconstruction using ei-
ther a specific wavelet (’wname’) or specific reconstruction fil-
ters (Lo R and Hi R).
Usage
X = waverec(C,L,’wname’)
reconstructs the signal X based on the multi-level wavelet
decomposition structure [C,L] (see wavedec). For
X = waverec(C,L,Lo R,Hi R),
Lo R is the reconstruction low-pass filter and Hi R is the
reconstruction high-pass filter.
(3) Functions for Wavelet Coefficients at a Given Level
• wrcoef
68 JIANZHONG WANG

function x = wrcoef(o,c,l,arg4,arg5,arg6)
WRCOEF
reconstructs the coefficients of a 1-D signal at any level,
given a wavelet decomposition structure (C and L) and either
a specified wavelet (’wname’) or specified reconstruction filters
(Lo R and Hi R).
Usage
X = wrcoef(’type’,C,L,’wname’,N)
computes the vector of reconstructed coefficients, based on
the wavelet decomposition structure [C,L]
(see WAVEDEC), at level N. ’wname’ is a string containing
the name of wavelet.
Argument ’type’ determines whether approximation (’type’
= ’a’) or detail (’type’ = ’d’) coefficients are reconstructed.
When ’type’ = ’a’, N is allowed to be 0, otherwise strictly pos-
itive N is required. Level N must be an integer such that N ≤
length(L)-2.
X = wrcoef(’type’,C,L,Lo R,Hi R,N)
computes coefficient as above, given the reconstruction you
specify.
X = wrcoef(’type’,C,L,’wname’) and
X = wrcoef(’type’,C,L,Lo R,Hi R)
reconstruct coefficients of maximum level N = length(L)-2.
• upcoef
function y = upcoef(o,x,arg3,arg4,arg5,arg6)
UPCOEF Direct reconstruction from 1-D wavelet coeffi-
cients.
Y = upcoef(O,X,’wname’,N)
computes the N steps reconstructed coefficients of vector
X. ’wname’ is a string containing the wavelet name. N must
be a strictly positive integer.
If O = ’a’, approximation coefficients are reconstructed.
If O = ’d’, detail coefficients are reconstructed.
Y = upcoef(O,X,’wname’,N,L)
computes the N steps reconstructed coefficients of vector
X and takes the length-L central portion of the result.
Instead of giving the wavelet name, you can give the filters.
For example, in
Y =upcoef(O,X,Lo R,Hi R,N) or
Y = upcoef(O,X,Lo R,Hi R,N,L),
Lo R is the reconstruction low-pass filter and Hi R is the
reconstruction high-pass filter.
Y = upcoef(O,X,’wname’) is equivalent to
Y = upcoef(O,X,’wname’,1).
Y = upcoef(O,X,Lo R,Hi R) is equivalent to
2. 1-D DISCRETE WAVELET TRANSFORM IN MATLAB 69

Y = upcoef(O,X,Lo R,Hi R,1).


• detcoef
function d = detcoef(c,l,n)
DETCOEF Extract 1-D detail coefficients.
Usage
D = detcoef(C,L,N)
extracts the detail coefficients at level N from the wavelet
decomposition structure [C,L] (see wavedec).
Level N must be an integer such that 1 ≤ N ≤ length(L)-2.
D = detcoef(C,L)
extracts the detail coefficients at last level n = length(L)-2.
• appcoef
function a = appcoef(C,L,arg3,arg4,arg5)
APPCOEF computes the approximation coefficients of a
one dimensional signal.
a = appcoef(C,L,’wname’,N)
computes the approximation coefficients at level N using
the wavelet decomposition structure [C,L] (see wavedec).
’wname’ is a string containing the wavelet name.
Level N must be an integer such that 0 ≤ N ≤ length(L)-2.
a = appcoef(C,L,’wname’)
extracts the approximation coefficients at the last level i.e.,
the level length(L)-2.
Instead of giving the wavelet name, you can give the filters.
For example in
a = appcoef(C,L,Lo R,Hi R) or
a = appcoef(C,L,Lo R,Hi R,N),
Lo R is the reconstruction low-pass filter and Hi R is the
reconstruction high-pass filter.
• upwlev
function [NC,NL,CA] = upwlev(L,L,arg3,arg4)
Usage
[NC,NL,CA] = upwlev(C,L,’wname’)
performs the single-level reconstruction of the wavelet de-
composition structure.
[C,L] giving the new one [NC,NL], and extract the last
approximation coefficients vector CA.
[C,L] is a decomposition at level
n = length(L)-2, so [NC,NL]
is the same decomposition at level n-1 and CA is the ap-
proximation coefficients vector at level n. ’wname’ is a string
containing the wavelet name,
70 JIANZHONG WANG

C is the original wavelet decomposition vector and L is the


corresponding book-keeping vector (for detailed storage infor-
mation, see wavedec). Instead of giving the wavelet name,
you can give the filters.
For example, in
[NC,NL,CA] = upwlev(C,L,Lo R,Hi R)
Lo R is the reconstruction low-pass filter and Hi R is the
reconstruction high-pass filter.
= dwt(s,’db1’)

Das könnte Ihnen auch gefallen