# qmf

Scaling and wavelet filter

## Syntax

## Description

changes the signs of the even-indexed elements of the reversed
vector filter coefficients `Y`

= qmf(`X`

)`X`

.

## Examples

### Create Quadrature Mirror Filter

This example shows how to create a quadrature mirror filter associated with the `db10`

wavelet.

Obtain the scaling filter associated with the `db10`

wavelet.

`sF = dbwavf("db10");`

`dbwavf`

normalizes the filter coefficients so that the norm is equal to $1/\sqrt{2}$. Normalize the coefficients so that the filter has norm equal to 1.

G = sqrt(2)*sF;

Obtain the wavelet filter coefficients by using `qmf`

. Plot the filters.

H = qmf(G); subplot(2,1,1) stem(G) title("Scaling (Lowpass) Filter G") grid on subplot(2,1,2) stem(H) title("Wavelet (Highpass) Filter H") grid on

Save the current extension mode. Set the extension mode to Periodization. Generate a random signal of length 64. Perform a single-level wavelet decomposition of the signal using `G`

and `H`

. For purposes of reproducibility, set the random seed to the default value.

origmode = dwtmode("status","nodisplay"); dwtmode("per","nodisplay") n = 64; rng default sig = randn(1,n); [a,d] = dwt(sig,G,H);

The lengths of the approximation and detail coefficients are both 32. Confirm that the filters preserve energy.

[sum(sig.^2) sum(a.^2)+sum(d.^2)]

`ans = `*1×2*
92.6872 92.6872

Compute the frequency responses of `G`

and `H`

. Zeropad the filters when taking the Fourier transform.

n = 128; F = 0:1/n:1-1/n; Gdft = fft(G,n); Hdft = fft(H,n);

Plot the magnitude of each frequency response.

figure plot(F(1:n/2+1),abs(Gdft(1:n/2+1)),"r") hold on plot(F(1:n/2+1),abs(Hdft(1:n/2+1)),"b") grid on title("Frequency Responses") xlabel("Normalized Frequency") ylabel("Magnitude") legend("Lowpass Filter","Highpass Filter","Location","east") hold off

Confirm the sum of the squared magnitudes of the frequency responses of `G`

and `H`

at each frequency is equal to 2.

sumMagnitudes = abs(Gdft).^2+abs(Hdft).^2; [min(sumMagnitudes) max(sumMagnitudes)]

`ans = `*1×2*
2.0000 2.0000

Confirm that the filters are orthonormal.

df = [G;H]; id = df*df'

`id = `*2×2*
1.0000 0.0000
0.0000 1.0000

Restore the original extension mode.

`dwtmode(origmode,"nodisplay")`

### Controlling Phase of Quadrature Mirror Filter

This example shows the effect of setting the phase parameter of the `qmf`

function.

Obtain the decomposition lowpass filter associated with a Daubechies wavelet.

`lowfilt = wfilters("db3");`

Use the `qmf`

function to obtain the decomposition lowpass filter for a wavelet. Then, compare the signs of the values when the `qmf`

phase parameter is set to 0 or 1. The reversed signs indicates a phase shift of $$\pi $$ radians, which is the same as multiplying the DFT by $${e}^{i\pi}$$.

p0 = qmf(lowfilt,0)

`p0 = `*1×6*
0.3327 -0.8069 0.4599 0.1350 -0.0854 -0.0352

p1 = qmf(lowfilt,1)

`p1 = `*1×6*
-0.3327 0.8069 -0.4599 -0.1350 0.0854 0.0352

Compute the magnitudes and display the difference between them. Unlike the phase, the magnitude is not affected by the sign reversals.

abs(p0)-abs(p1)

`ans = `*1×6*
0 0 0 0 0 0

## Input Arguments

`X`

— Filter coefficients

vector

Filter coefficients, specified as a vector.

**Data Types: **`single`

| `double`

`P`

— Phase parameter

`0`

(default) | `1`

Phase parameter, specified as follows.

`0`

— Change signs of even-indexed elements of the reversed vector`X`

`1`

— Change signs of odd-indexed elements of the reversed vector`X`

**Data Types: **`single`

| `double`

## More About

### Quadrature Mirror Filters

Let `x`

be a finite energy signal.
Two filters *F _{0}* and

*F*are quadrature mirror filters (QMF) if, for any

_{1}*x*,

$${\Vert {y}_{0}\Vert}^{2}+{\Vert {y}_{1}\Vert}^{2}={\Vert x\Vert}^{2}$$

where
*y _{0}* is a decimated
version of the signal

*x*filtered with

*F*, so

_{0}*y*is defined by

_{0}*x*=

_{0}*F*(

_{0}*x*) and

*y*(

_{0}*n*) =

*x*(2

_{0}*n*). Similarly,

*y*is defined by

_{1}*x*=

_{1}*F*(

_{1}*x*) and

*y*(

_{1}*n*) =

*x*(2

_{1}*n*). This property ensures a perfect reconstruction of the associated two-channel filter banks scheme (see [1] p. 103).

For example, if *F _{0}* is a
Daubechies scaling filter with norm equal to 1 and

*F*=

_{1}`qmf`

(*F*), then the transfer functions

_{0}*F*(

_{0}*z*) and

*F*(

_{1}*z*) of the filters

*F*and

_{0}*F*satisfy the condition:

_{1}$$|{F}_{0}(z){|}^{2}+|{F}_{1}(z){|}^{2}=2.$$

## References

[1] Strang, Gilbert, and
Truong Nguyen. *Wavelets and Filter Banks*. Rev. ed.
Wellesley, Mass: Wellesley-Cambridge Press, 1997.

## Extended Capabilities

### C/C++ Code Generation

Generate C and C++ code using MATLAB® Coder™.

## Version History

**Introduced before R2006a**

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)