This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dwt

Single-level 1-D discrete wavelet transform

Syntax

[cA,cD] = dwt(x,wname)
[cA,cD] = dwt(x,LoD,HiD)
[cA,cD] = dwt(___,'mode',extmode)

Description

example

[cA,cD] = dwt(x,wname) returns the single-level discrete wavelet transform (DWT) of the vector x using the wavelet specified by wname. The wavelet must be recognized by wavemngr. dwt returns the approximation coefficients vector cA and detail coefficients vector cD of the DWT.

Note

If your application requires a multilevel wavelet decomposition, consider using wavedec.

example

[cA,cD] = dwt(x,LoD,HiD) returns the single-level DWT using the scaling (lowpass) filter LoD and wavelet (highpass) filter HiD. The filters must have the same even length.

[cA,cD] = dwt(___,'mode',extmode) returns the single-level DWT with the specified extension mode extmode. For more information, see dwtmode.

Examples

collapse all

Obtain the single-level DWT of the noisy Doppler signal using a wavelet name.

load noisdopp;
[cA,cD] = dwt(noisdopp,'sym4');

Reconstruct a smoothed version of the signal using the approximation coefficients. Plot and compare with the original signal.

xrec = idwt(cA,zeros(size(cA)),'sym4');
plot(noisdopp)
hold on
grid on
plot(xrec)
legend('Original','Reconstruction')

Obtain the single-level DWT of a noisy Doppler signal using the wavelet (highpass) and scaling (lowpass) filters.

load noisdopp;
[LoD,HiD] = wfilters('bior3.5','d');
[cA,cD] = dwt(noisdopp,LoD,HiD);

Create a DWT filter bank that can be applied to the noisy Doppler signal using the same wavelet. Obtain the highpass and lowpass filters from the filter bank.

len = length(noisdopp);
fb = dwtfilterbank('SignalLength',len,'Wavelet','bior3.5');
[lo,hi] = filters(fb);

For the bior3.5 wavelet, lo and hi are 12-by-2 matrices. lo are the lowpass filters, and hi are the highpass filters. The first columns of lo and hi are used for analysis and the second columns are used for synthesis. Compare the first column of lo and hi with LoD and HiD respectively. Confirm they are equal.

disp('Lowpass Analysis Filters')
Lowpass Analysis Filters
[lo(:,1) LoD']
ans = 12×2

   -0.0138   -0.0138
    0.0414    0.0414
    0.0525    0.0525
   -0.2679   -0.2679
   -0.0718   -0.0718
    0.9667    0.9667
    0.9667    0.9667
   -0.0718   -0.0718
   -0.2679   -0.2679
    0.0525    0.0525
      ⋮

disp('Highpass Analysis Filters')
Highpass Analysis Filters
[hi(:,1) HiD']
ans = 12×2

         0         0
         0         0
         0         0
         0         0
   -0.1768   -0.1768
    0.5303    0.5303
   -0.5303   -0.5303
    0.1768    0.1768
         0         0
         0         0
      ⋮

Plot the one-sided magnitude frequency responses of the first-level wavelet and scaling filters.

[psidft,f,phidft] = freqz(fb);
level = 1;
plot(f(len/2+1:end),abs(phidft(level,len/2+1:end)))
hold on
plot(f(len/2+1:end),abs(psidft(level,len/2+1:end)))
grid on
legend('Scaling Filter','Wavelet Filter')
title('First-Level One-sided Frequency Responses')
xlabel('Normalized Frequency (cycles/sample)')
ylabel('Magnitude')

Input Arguments

collapse all

Input data, specified as a real-valued vector.

Data Types: double

Analyzing wavelet used to the compute the single-level DWT, specified as a character vector or string scalar. The wavelet must be recognized by wavemngr. The analyzing wavelet is from one of the following wavelet families: Daubechies, Coiflets, Symlets, Fejér-Korovkin, Discrete Meyer, Biorthogonal, and Reverse Biorthogonal. See wfilters for the wavelets available in each family.

Example: 'db4'

Scaling (lowpass) filter, specified as an even-length real-valued vector. LoD must be the same length as HiD. See wfilters for details.

Data Types: double

Wavelet (highpass) filter, specified as an even-length real-valued vector. HiD must be the same length as LoD. See wfilters for details.

Data Types: double

Extension mode used when performing the DWT, specified as one of the following:

mode

DWT Extension Mode

'zpd'

Zero extension

'sp0'

Smooth extension of order 0

'spd' (or 'sp1')

Smooth extension of order 1

'sym' or 'symh'

Symmetric extension (half point): boundary value symmetric replication

'symw'

Symmetric extension (whole point): boundary value symmetric replication

'asym' or 'asymh'

Antisymmetric extension (half point): boundary value antisymmetric replication

'asymw'

Antisymmetric extension (whole point): boundary value antisymmetric replication

'ppd'

Periodized extension (1)

'per'

Periodized extension (2)

If the signal length is odd, wextend adds to the right an extra sample that is equal to the last value, and performs the extension using the 'ppd' mode. Otherwise, 'per' reduces to 'ppd'. This rule also applies to images.

The global variable managed by dwtmode specifies the default extension mode. See dwtmode for extension mode descriptions.

Example: [cA,cD] = dwt(x,'db4','mode','symw') returns the single-level DWT of x using the order 4 Daubechies extremal phase wavelet and whole point symmetric extension.

Output Arguments

collapse all

Approximation coefficients obtained from the wavelet decomposition, returned as a vector. Convolving the input signal x with the scaling filter LoD, followed by dyadic decimation, yields the approximation coefficients. Let sx = size(x) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, cA is a vector of length ceil(sx/2).

  • For the other extension modes, cA is a vector of length floor((sx+lf-1)/2).

Data Types: double

Detail coefficients obtained from the wavelet decomposition, returned as a vector. Convolving the input signal x with the wavelet filter HiD, followed by dyadic decimation, yields the detail coefficients. Let sx = size(x) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, cD is a vector of length ceil(sx/2).

  • For the other extension modes, cD is a vector of length floor((sx+lf-1)/2).

Data Types: double

Algorithms

Starting from a signal s of length N, two sets of coefficients are computed: approximation coefficients cA1, and detail coefficients cD1. Convolving s with the scaling filter LoD, followed by dyadic decimation, yields the approximation coefficients. Similarly, convolving s with the wavelet filter HiD, followed by dyadic decimation, yields the detail coefficients.

where

  • — Convolve with filter X

  • 2 — Downsample (keep the even-indexed elements)

The length of each filter is equal to 2n. If N = length(s), the signals F and G are of length N + 2n −1 and the coefficients cA1 and cD1 are of length floor(N12)+n.

To deal with signal-end effects resulting from a convolution-based algorithm, a global variable managed by dwtmode defines the kind of signal extension mode used. The possible options include zero-padding and symmetric extension, which is the default mode.

Note

For the same input, this dwt function and the DWT block in the DSP System Toolbox™ do not produce the same results. The DWT block is designed for real-time implementation while Wavelet Toolbox™ software is designed for analysis, so the products handle boundary conditions and filter states differently.

To make the dwt function output match the DWT block output, set the function boundary condition to zero-padding by typing dwtmode('zpd') at the MATLAB® command prompt. To match the latency of the DWT block, which is implemented using FIR filters, add zeros to the input of the dwt function. The number of zeros you add must be equal to half the filter length.

References

[1] Daubechies, I. Ten Lectures on Wavelets. CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: Society for Industrial and Applied Mathematics, 1992.

[2] Mallat, S. G. “A Theory for Multiresolution Signal Decomposition: The Wavelet Representation.” IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 11, Issue 7, July 1989, pp. 674–693.

[3] Meyer, Y. Wavelets and Operators. Translated by D. H. Salinger. Cambridge, UK: Cambridge University Press, 1995.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a