Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

The wavelet packet method is a generalization of wavelet decomposition that offers a richer signal analysis.

Wavelet packet atoms are waveforms indexed by three naturally interpreted parameters: position, scale (as in wavelet decomposition), and frequency.

For a given orthogonal wavelet function, we generate a library
of bases called *wavelet packet bases*. Each of
these bases offers a particular way of coding signals, preserving
global energy, and reconstructing exact features. The wavelet packets
can be used for numerous expansions of a given signal. We then select
the most suitable decomposition of a given signal with respect to
an entropy-based criterion.

There exist simple and efficient algorithms for both wavelet packet decomposition and optimal decomposition selection. We can then produce adaptive filtering algorithms with direct applications in optimal signal coding and data compression.

In the orthogonal wavelet decomposition procedure, the generic step splits the approximation coefficients into two parts. After splitting we obtain a vector of approximation coefficients and a vector of detail coefficients, both at a coarser scale. The information lost between two successive approximations is captured in the detail coefficients. Then the next step consists of splitting the new approximation coefficient vector; successive details are never reanalyzed.

In the corresponding wavelet packet situation, each detail coefficient vector is also decomposed into two parts using the same approach as in approximation vector splitting. This offers the richest analysis: the complete binary tree is produced as shown in the following figure.

**Wavelet Packet Decomposition Tree at Level3**

The idea of this decomposition is to start from a scale-oriented decomposition, and then to analyze the obtained signals on frequency subbands.

The following simple examples illustrate certain differences between wavelet analysis and wavelet packet analysis.

The spectral analysis of wide-sense stationary signals using the Fourier transform is well-established. For nonstationary signals, there exist local Fourier methods such as the short-time Fourier transform (STFT). See Short-Time Fourier Transform for a brief description.

Because wavelets are localized in time and frequency, it is
possible to use wavelet-based counterparts to the STFT for the time-frequency
analysis of nonstationary signals. For example, it is possible to
construct the scalogram (`wscalogram`

)
based on the continuous wavelet transform (CWT). However, a potential
drawback of using the CWT is that it is computationally expensive.

The discrete wavelet transform (DWT) permits a time-frequency decomposition of the input signal, but the degree of frequency resolution in the DWT is typically considered too coarse for practical time-frequency analysis.

As a compromise between the DWT- and CWT-based techniques, wavelet
packets provide a computationally-efficient alternative with sufficient
frequency resolution. You can use `wpspectrum`

to
perform a time-frequency analysis of your signal using wavelet packets.

The following examples illustrate the use of wavelet packets
to perform a local spectral analysis. The following examples also
use `spectrogram`

from the Signal Processing Toolbox™ software
as a benchmark to compare against the wavelet packet spectrum. If
you do not have the Signal Processing Toolbox software, you can
simply run the wavelet packet spectrum examples.

Wavelet packet spectrum of a sine wave.

fs = 1000; % sampling rate t = 0:1/fs:2; % 2 secs at 1kHz sample rate y = sin(256*pi*t); % sine of period 128 level = 6; wpt = wpdec(y,level,'sym8'); [Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');

If you have the Signal Processing Toolbox software, you can compute the short-time Fourier transform.

figure; windowsize = 128; window = hanning(windowsize); nfft = windowsize; noverlap = windowsize-1; [S,F,T] = spectrogram(y,window,noverlap,nfft,fs); imagesc(T,F,log10(abs(S))) set(gca,'YDir','Normal') xlabel('Time (secs)') ylabel('Freq (Hz)') title('Short-time Fourier Transform spectrum')

Sum of two sine waves with frequencies of 64 and 128 hertz.

fs = 1000; t = 0:1/fs:2; y = sin(128*pi*t) + sin(256*pi*t); % sine of periods 64 and 128. level = 6; wpt = wpdec(y,level,'sym8'); [Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');

If you have the Signal Processing Toolbox software, you can compute the short-time Fourier transform.

figure; windowsize = 128; window = hanning(windowsize); nfft = windowsize; noverlap = windowsize-1; [S,F,T] = spectrogram(y,window,noverlap,nfft,fs); imagesc(T,F,log10(abs(S))) set(gca,'YDir','Normal') xlabel('Time (secs)') ylabel('Freq (Hz)') title('Short-time Fourier Transform spectrum')

Signal with an abrupt change in frequency from 16 to 64 hertz at two seconds.

fs = 500; t = 0:1/fs:4; y = sin(32*pi*t).*(t<2) + sin(128*pi*t).*(t>=2); level = 6; wpt = wpdec(y,level,'sym8'); [Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');

If you have the Signal Processing Toolbox software, you can compute the short-time Fourier transform.

figure; windowsize = 128; window = hanning(windowsize); nfft = windowsize; noverlap = windowsize-1; [S,F,T] = spectrogram(y,window,noverlap,nfft,fs); imagesc(T,F,log10(abs(S))) set(gca,'YDir','Normal') xlabel('Time (secs)') ylabel('Freq (Hz)') title('Short-time Fourier Transform spectrum')

Wavelet packet spectrum of a linear chirp.

fs = 1000; t = 0:1/fs:2; y = sin(256*pi*t.^2); level = 6; wpt = wpdec(y,level,'sym8'); [Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');

Wavelet packet spectrum of quadratic chirp.

y = wnoise('quadchirp',10); len = length(y); t = linspace(0,5,len); fs = 1/t(2); level = 6; wpt = wpdec(y,level,'sym8'); [Spec,Time,Freq] = wpspectrum(wpt,fs,'plot');

windowsize = 128; window = hanning(windowsize); nfft = windowsize; noverlap = windowsize-1; imagesc(T,F,log10(abs(S))) set(gca,'YDir','Normal') xlabel('Time (secs)') ylabel('Freq (Hz)') title('Short-time Fourier Transform spectrum')

The computation scheme for wavelet packets generation is easy
when using an orthogonal wavelet. We start with the two filters of
length 2* N*, where

`(`*n*)

and `(`*n*)

,
correspond to the wavelet.Now by induction let us define the following sequence of functions:

(*W*_{n}(* x*),

by

$${W}_{2n}(x)=\sqrt{2}{\displaystyle \sum _{k=0}^{2N-1}h(k){W}_{n}(2x-k)}$$

$${W}_{2n+1}(x)=\sqrt{2}{\displaystyle \sum _{k=0}^{2N-1}g(k){W}_{n}(2x-k)}$$

where *W*_{0}`(`

=
φ* x*)

`(`*x*)

is the scaling function
and `(`*x*)

=
ψ`(`*x*)

is the wavelet function.For example for the Haar wavelet we have

$$N=1,h(0)=h(1)=\frac{1}{\sqrt{2}}$$

and

$$g(0)=-g(1)=\frac{1}{\sqrt{2}}$$

The equations become

$${W}_{2n}(x)={W}_{n}(2x)+{W}_{n}(2x-1)$$

and

$${W}_{2n+1}(x)={W}_{n}(2x)-{W}_{n}(2x-1)$$

*W*_{0}`(`

=
φ* x*)

`(`*x*)

is the `(`*x*)

=
ψ`(`*x*)

is the Haar wavelet,
both supported in [0, 1]. Then we can obtain For * n* = 0 to 7, we have the

**Haar Wavelet Packets**

This can be obtained using the following command:

[wfun,xgrid] = wpfun('db1',7,5);

which returns in `wfun`

the approximate values
of * W_{n}* for

`xgrid`

.Starting from more regular original wavelets and using a similar
construction, we obtain smoothed versions of this system of * W*-functions,
all with support in the interval [0, 2

`db2`

wavelet.*db*2 Wavelet Packets

Starting from the functions $$({W}_{n}(x),n\in N)$$ and following the same line leading to orthogonal wavelets, we consider the three-indexed family of analyzing functions (the waveforms):

$$({W}_{j,n,k}(x)={2}^{-j/2}{W}_{n}({2}^{-j}x-k)$$

where * n*∊

As in the wavelet framework, * k* can be interpreted
as a time-localization parameter and

The basic idea of the wavelet packets is that for fixed values
of * j* and

In fact, examining carefully the wavelet packets displayed in Haar Wavelet Packets and *db*2 Wavelet Packets, the naturally
ordered * W_{n}* for

`db1`

wavelet
packets, we have the following.

So, to restore the property that the main frequency increases monotonically
with the order, it is convenient to define the *frequency
order* obtained from the natural one recursively.

As can be seen in the previous figures, *W _{r}*

`(`*x*)

"oscillates"
approximately To analyze a signal (the chirp of Example 2 for instance), it is better to plot the wavelet packet coefficients following the frequency order from the low frequencies at the bottom to the high frequencies at the top, rather than naturally ordered coefficients.

When plotting the coefficients, the various options related to the "Frequency" or "Natural" order choice are available using the Wavelet Analyzer app.

These options are also available from command-line mode when
using the `wpviewcf`

function.

The set of functions *W*_{j,n} = `(`

is
the (*W*_{j,n,k}(* x*),

**Wavelet Packets Organized in a Tree; Scale j Defines
Depth and Frequency n Defines Position in the Tree**

The notation W*_{j,n}*,
where

We have $${W}_{0,0}=(\varphi (x-k),k\in Z)$$, and $${W}_{1,1}=(\psi (\frac{x}{2}-k),k\in Z)$$.

It turns out that the library of wavelet packet bases contains the
wavelet basis and also several other bases. Let us have a look at
some of those bases. More precisely, let *V*_{0} denote
the space (spanned by the family *W*_{0,0} ) in which the signal to be analyzed lies; then
(*W*_{d}_{,1}; * d* ≥
1) is an orthogonal basis of

For every strictly positive integer * D*, (

We also know that the family of functions {(*W _{j}*

This last property gives a precise interpretation of splitting in the wavelet packet organization tree, because all the developed nodes are of the form shown in the figure Wavelet Packet Tree: Split and Merge.

**Wavelet Packet Tree: Split and Merge**

It follows that the leaves of every connected binary subtree of the complete tree correspond to an orthogonal basis of the initial space.

For a finite energy signal belonging to *V*_{0},
any wavelet packet basis will provide exact reconstruction and offer
a specific way of coding the signal, using information allocation
in frequency scale subbands.

Based on the organization of the wavelet packet library, it is natural to count the decompositions issued from a given orthogonal wavelet.

A signal of length * N* = 2

As this number may be very large, and since explicit enumeration is generally unmanageable, it is interesting to find an optimal decomposition with respect to a convenient criterion, computable by an efficient algorithm. We are looking for a minimum of the criterion.

Functions verifying an additivity-type property are well suited
for efficient searching of binary-tree structures and the fundamental
splitting. Classical entropy-based
criteria match these conditions and describe information-related properties
for an accurate representation of a given signal. Entropy is a common
concept in many fields, mainly in signal processing. Let us list four
different entropy criteria (see [CoiW92]); many others are available
and can be easily integrated (type `help`

`wentropy`

).
In the following expressions * s* is the signal and
(

The entropy * E* must be an additive cost
function such that

$$E(s)={\displaystyle {\sum}_{i}E({s}_{i})}$$

The (nonnormalized) Shannon entropy

$$E1({s}_{i})=-{s}_{i}^{2}\mathrm{log}({s}_{i}^{2})$$

so

$$E1(s)=-{\displaystyle {\sum}_{i}{s}_{i}^{2}\mathrm{log}({s}_{i}^{2})}$$

with the convention 0log(0) = 0.

The concentration in

norm with 1 ℜ ≤*l*^{p}*p*$$E2({s}_{i})={\left|{s}_{i}\right|}^{p}$$

so

$$E2(s)={\displaystyle {\sum}_{i}{\left|{s}_{i}\right|}^{p}}={\left|s\right|}_{p}^{p}$$

The logarithm of the "energy" entropy

$$E3({s}_{i})=\mathrm{log}({s}_{i}^{2})$$

so

$$E3(s)={\displaystyle {\sum}_{i}\mathrm{log}({s}_{i}^{2})}$$

with the convention log(0) = 0.

The threshold entropy

$$E4({s}_{i})=1$$ if $$\left|{s}_{i}\right|>\epsilon $$ and 0 elsewhere, so

4(*E*) = # {*s*such that $$\left|{s}_{i}\right|>\epsilon $$} is the number of time instants when the signal is greater than a threshold ε.*i*

These entropy functions are available using the `wentropy`

file.

Generate a signal of energy equal to 1.

= ones(1,16)*0.25;*s*Compute the Shannon entropy of

.*s*e1 = wentropy(s,'shannon') e1 = 2.7726

Compute the

*l*^{1.5}entropy of, equivalent to*s*`norm(s,1.5)`

^{1.5}.e2 = wentropy(s,'norm',1.5) e2 = 2

Compute the "log energy" entropy of

.*s*e3 = wentropy(s,'log energy') e3 = -44.3614

Compute the threshold entropy of

using a threshold value of 0.24.*s*e4 = wentropy(s,'threshold', 0.24) e4 = 16

This simple example illustrates the use of entropy to determine whether a new splitting is of interest to obtain a minimum-entropy decomposition.

We start with a constant original signal. Two pieces of information are sufficient to define and to recover the signal (i.e., length and constant value).

w00 = ones(1,16)*0.25;

Compute entropy of original signal.

e00 = wentropy(w00,'shannon') e00 = 2.7726

Then split

`w00`

using the haar wavelet.[w10,w11] = dwt(w00,'db1');

Compute entropy of approximation at level 1.

e10 = wentropy(w10,'shannon') e10 = 2.0794

The detail of level 1,

`w11`

, is zero; the entropy`e11`

is zero. Due to the additivity property the entropy of decomposition is given by`e10+e11=2.0794`

. This has to be compared to the initial entropy`e00=2.7726`

. We have`e10 + e11 < e00`

, so the splitting is interesting.Now split

`w10`

(not`w11`

because the splitting of a null vector is without interest since the entropy is zero).[w20,w21] = dwt(w10,'db1');

We have

`w20=0.5*ones(1,4)`

and`w21`

is zero. The entropy of the approximation level 2 ise20 = wentropy(w20,'shannon') e20 = 1.3863

Again we have

`e20 + 0 < e10`

, so splitting makes the entropy decrease.Then

[w30,w31] = dwt(w20,'db1'); e30 = wentropy(w30,'shannon') e30 = 0.6931 [w40,w41] = dwt(w30,'db1') w40 = 1.0000 w41 = 0 e40 = wentropy(w40,'shannon') e40 = 0

In the last splitting operation we find that only one piece of information is needed to reconstruct the original signal. The wavelet basis at level 4 is a best basis according to Shannon entropy (with null optimal entropy since

`e40+e41+e31+e21+e11 = 0`

).Perform wavelet packets decomposition of the signal

defined in example 1.*s*t = wpdec(s,4,'haar','shannon');

The wavelet packet tree in Entropy Values shows the nodes labeled with original entropy numbers.

**Entropy Values**Compute the best tree.

bt = besttree(t);

The best tree is shown in the following figure. In this case, the best tree corresponds to the wavelet tree. The nodes are labeled with optimal entropy.

**Optimal Entropy Values**

Using wavelet packets requires tree-related actions and labeling. The implementation of the user interface is built around this consideration. For more information on the technical details, see the reference pages.

The complete binary tree of depth * D* corresponding
to a wavelet packet decomposition tree developed
at level

We have the following interesting subtrees.

Decomposition Tree | Subtree Such That the Set of Leaves Is a Basis |
---|---|

Wavelet packets decomposition tree | Complete binary tree: WPT of depth |

Wavelet packets optimal decomposition tree | Binary subtree of WPT |

Wavelet packets best-level tree | Complete binary subtree of WPT |

Wavelet decomposition tree | Left unilateral binary subtree of WPT of depth |

Wavelet best-basis tree | Left unilateral binary subtree of WPT |

We deduce the following definitions of optimal decompositions,
with respect to an entropy criterion * E*.

Decompositions | Optimal Decomposition | |
---|---|---|

Wavelet packet decompositions | Search among 2 | Search among |

Wavelet decompositions | Search among | Search among |

For any nonterminal node, we use the following basic step to
find the optimal subtree with respect to a given entropy criterion * E* (where

Entropy Condition | Action on Tree and on Entropy Labeling |
---|---|

$$E(node)\le {\displaystyle \sum _{c\text{childofnode}}Eopt(c)}$$ | If ( (Eopt) = node(E)node |

$$E(node)>{\displaystyle \sum _{c\text{childofnode}}Eopt(c)}$$ | Split and set $$Eopt(node)={\displaystyle \sum _{c\text{childofnode}}Eopt(c)}$$ |

with the natural initial condition on the reference tree,* Eopt*`(`

= * t*)

`(`*t*)

for
each terminal node You can use the function `wprcoef`

to
reconstruct an approximation to your signal from any node in the wavelet
packet tree. This is true irrespective of whether you are working
with a full wavelet packet tree, or a subtree determined by an optimality
criterion. Use `wpcoef`

if you
want to extract the wavelet packet coefficients from a node without
reconstructing an approximation to the signal.

Load the noisy Doppler signal.

load noisdopp

Compute the wavelet packet decomposition down to level 5 using
the `sym4`

wavelet. Use the periodization mode.

dwtmode('per'); T = wpdec(noisdopp,5,'sym4'); plot(T)

Plot the binary wavelet packet tree and click on the (4,1) doublet (node 16).

Extract the wavelet packet coefficients from node 16.

wpc = wpcoef(T,16); % wpc is length 64

Obtain an approximation to the signal from node 16.

rwpc = wprcoef(T,16); % rwpc is length 1024 plot(noisdopp,'k'); hold on; plot(rwpc,'b','linewidth',2); axis tight;

Determine the optimum binary wavelet packet tree.

Topt = besttree(T); % plot the best tree plot(Topt)

Reconstruct an approximation to the signal from the (3,0) doublet (node 7).

rsig = wprcoef(Topt,7); % rsig is length 1024 plot(noisdopp,'k'); hold on; plot(rsig,'b','linewidth',2); axis tight;

If you know which doublet in the binary wavelet packet tree
you want to extract, you can determine the node corresponding to that
doublet with `depo2ind`

.

For example, to determine the node corresponding to the doublet (3,0), enter:

Node = depo2ind(2,[3 0]);

Exactly as in the wavelet decomposition case, the preceding 1-D framework can be extended to image analysis. Minor direct modifications lead to quaternary tree-related definitions. An example is shown the following figure for depth 2.

**Quaternary Tree of Depth 2**

In the wavelet packet framework, compression and denoising ideas
are identical to those developed in the wavelet framework. The only
new feature is a more complete analysis that provides increased flexibility.
A single decomposition using wavelet packets generates a large number
of bases. You can then look for the best representation with respect
to a design objective, using the `besttree`

with
an entropy function.

Was this topic helpful?