Download as pdf or txt
Download as pdf or txt
You are on page 1of 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 Toolbox. 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 particular wavelet lters (Lo D and Hi D) you specify. Usage [CA,CD] = dwt(X,wname) computes the approximation coecients vector CA and detail coecients 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 lters as input: Lo D is the decomposition low-pass lter and Hi D is the decomposition high-pass lter. Lo D and Hi D must be the same length. If lx = length(X) and lf is the length of lters 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 decomposition using either a specic wavelet (wname) or specic wavelet decomposition lters. 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 integer. 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 lter and Hi D is the decomposition high-pass lter. 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 coecients of the wavelet decomposition while wavecoef(J) is the N-level wavelet coecients 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 particular wavelet reconstruction lters you specify. Usage X = idwt(CA,CD,wname) returns the single-level reconstructed approximation coecients vector X based on approximation and detail coecients vectors CA and CD, and using the wavelet wname. X = idwt(CA,CD,Lo R,Hi R) reconstructs approximation coecients vector X as above, using lters you specify: Lo R is the reconstruction low-pass lter and Hi R is the reconstruction high-pass lter. Lo R and Hi R must be the same length. If la = length(CA) = length(CD) and lf is the length of the lters, 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 either a specic wavelet (wname) or specic reconstruction lters (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 lter and Hi R is the reconstruction high-pass lter. (3) Functions for Wavelet Coecients at a Given Level wrcoef

68

JIANZHONG WANG

function x = wrcoef(o,c,l,arg4,arg5,arg6) WRCOEF reconstructs the coecients of a 1-D signal at any level, given a wavelet decomposition structure (C and L) and either a specied wavelet (wname) or specied reconstruction lters (Lo R and Hi R). Usage X = wrcoef(type,C,L,wname,N) computes the vector of reconstructed coecients, 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) coecients are reconstructed. When type = a, N is allowed to be 0, otherwise strictly positive 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 coecient as above, given the reconstruction you specify. X = wrcoef(type,C,L,wname) and X = wrcoef(type,C,L,Lo R,Hi R) reconstruct coecients of maximum level N = length(L)-2. upcoef function y = upcoef(o,x,arg3,arg4,arg5,arg6) UPCOEF Direct reconstruction from 1-D wavelet coecients. Y = upcoef(O,X,wname,N) computes the N steps reconstructed coecients of vector X. wname is a string containing the wavelet name. N must be a strictly positive integer. If O = a, approximation coecients are reconstructed. If O = d, detail coecients are reconstructed. Y = upcoef(O,X,wname,N,L) computes the N steps reconstructed coecients of vector X and takes the length-L central portion of the result. Instead of giving the wavelet name, you can give the lters. 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 lter and Hi R is the reconstruction high-pass lter. 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 coecients. Usage D = detcoef(C,L,N) extracts the detail coecients 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 coecients at last level n = length(L)-2. appcoef function a = appcoef(C,L,arg3,arg4,arg5) APPCOEF computes the approximation coecients of a one dimensional signal. a = appcoef(C,L,wname,N) computes the approximation coecients 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 coecients at the last level i.e., the level length(L)-2. Instead of giving the wavelet name, you can give the lters. 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 lter and Hi R is the reconstruction high-pass lter. 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 decomposition structure. [C,L] giving the new one [NC,NL], and extract the last approximation coecients 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 approximation coecients 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 information, see wavedec). Instead of giving the wavelet name, you can give the lters. For example, in [NC,NL,CA] = upwlev(C,L,Lo R,Hi R) Lo R is the reconstruction low-pass lter and Hi R is the reconstruction high-pass lter. = dwt(s,db1)

You might also like