# Connexions

You are here: Home » Content » The Discrete Wavelet Transform

### Recently Viewed

This feature requires Javascript to be enabled.

# The Discrete Wavelet Transform

Module by: Mark Eastaway. E-mail the author

Summary: An explanation of the DWT code r_dwt.m

## Introduction to the Discrete Wavelet Transform (DWT)

A discrete wavelet transform (DWT) is a sampled wavelet function.  Rather than calculate the wavelet coefficients at every point, the DWT uses only a subset of positions and scales.  This method results in an accurate and more efficient manner of a wavelet transform.

The DWT is similar but more versatile that the Fourier series. The DWT can be made periodic but it can also be applied to non-periodic transient signals.

The “mother” wavelet function generates the set of expansion functions with integer indices j, k.

ψ j,k (t) = 2 j/2 (2 j t - k) j,k Z

Although this expansion is known as the discrete wavelet transform, it might be better served to be called a wavelet series as it is a series expansion that maps the function of a continuous variable onto a set of coefficients. The series expansion of the DWT is below:

f(t)= j,k a j,k ψ j,k ( t )

Where coefficients aj,k are the discrete wavelet transform of the signal.

. An extremely interesting aspect of the DWT is that it matches a similar expansion that was developed completely independently from it. The use of filter banks to represent signals is actually just another representation of the vector space notation developed for wavelets, where the scaling function represents a low pass filter and (by its required orthogonality) the wavelet function represents a high pass filter.

The use of filter banks to explain DWTs helps explain the process in greater clarity, and is also the method used to implement DWTs in algorithms for computer programs.

We want to have a scaling function and a wavelet function that satisfy all necessary conditions, and we also want to have the input signal for which to take the DWT of. The number of ‘stages’ (which we will explain later) is determined by the length of the input. If the length of the input is 2n then the maximum number of stages is n.

The method we use to calculate the DWT of the signal is straightforward. First, we filter the signal with both our scaling and wavelet functions (our lowpass and highpass filters). This is shown in .

Because this method will give us two times as many coefficients as we started with (due to filtering twice) we must down sample to arrive at the same number of coefficients as our input signal. This does not lead to aliasing, however, as the information found in one set of coefficients will provide enough information to perfectly reconstruct the other coefficients. Downsampling is achieved by simply removing every other coefficient (It doesn’t matter whether you remove the odd coefficients or the even coefficients, but for convenience sakes we always remove the even coefficients). shows this process.

22

We have now arrived at a single level of the DWT. What is interesting about this transform, however, is you can perform multiple levels of the DWT. The amount of levels you are limited to can be found by taking the log10(Length of your signal) / log10(2). Or, in simpler terms, if your signal is length 2n then the maximum number of levels you can take is simply n. If your signal is length 16, then you can take up to 4 levels of DWT on it. Each progressive level gets into finer and finer details. Since most of the important information in signals is in the lower frequency bands, then you will usually want to perform the next level of the DWT on the lowpassed coefficients. However, you can perform the DWT on the high passed coefficients or even both, if your application calls for such a use. The process of multilevel DWT is shown in Figure 3:

In this case the DWT is comprised of cD1 cD2 cD­3 and cA3. There are 3 levels, so this would work for a length 8 signal and larger (as you don’t have to evaluate the maximum amount of levels in a DWT).

## How to use our code (R_dwt.m)

x = R_dwt(fx,scaling,wavelet,scales,graphs)

The function is called using the R_dwt function name. The parameter fx is the signal we want to get the DWT of. The parameter scaling is the hn output given by our R_daub code, or the scaling function of another wavelet function. The parameter wavelet is the wavelet coefficients given by the h1n output of our R_daub code, or the wavelet coefficients of any other wavelet function. The parameter scales is the amount of levels wanted in the DWT. The parameter graphs is 0 for no graphs, 1 for graphs of the DWT. The output x is the DWT of the signal fx.

An error will be thrown if there are too many scales for the length of the signal. If there are no parameters for scales or graphs they will be initialized to 1 and 0, respectively.

Another error will be thrown if the input signal is not even, as we require an even signal.

Our function uses recursion to process multiple levels, instead of a loop. This requires the use of a helper function (r_dwthelper.m) that functions the exact same way as the R_dwt, except it also takes the current level as an input as well. This is so we are able to keep track of what current level we are on, as well as the total levels we need to go through. The code of r_dwthelper is exactly the same as r_dwt, except we do not initialize variable arguments since we will always have the correct number of arguments passed.

Examples

This following code will perform a single level DWT on our noisy sine wave signal, sig, using a length 8 daubechies wavelet.

sig = createsignal();

 sig = sig(1:64);

 [h0 h1 hr0 hr1] = r_daub(8);

 dwt = r_dwt(sig, h0, h1, 1, 1);

Our original signal:

Our program output:

Our final DWT:

Code for 2 levels of dwt:

sig = createsignal();

 sig = sig(1:64);

 [h0 h1 hr0 hr1] = r_daub(8);

 dwt = r_dwt(sig, h0, h1, 2, 1);

Output of THIS function:

Notice that we can see the higher frequencies being filtered out more and more per step!!

## Content actions

PDF | EPUB (?)

### What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

#### Definition of a lens

##### Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

##### What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

##### Who can create a lens?

Any individual member, a community, or a respected organization.

##### What are tags?

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks