# wavedec3

3-D wavelet decomposition

## Syntax

## Description

## Examples

### 3-D Wavelet Transform

Find the 3-D DWT of a volume. Construct 8-by-8-by-8 matrix of integers 1 to 64 and make the data 3-D.

M = magic(8); X = repmat(M,[1 1 8]);

Obtain the 3-D discrete wavelet transform at level 1 using the Haar wavelet and the default whole-point symmetric extension mode.

`wd1 = wavedec3(X,1,'db1');`

### Coefficient Order in 3-D Wavelet Transform

Compare the output of `wavedec3`

and `dwt3`

to illustrate the ordering of the 3-D wavelet coefficients described in the `dec`

field description.

X = reshape(1:512,8,8,8); dwtOut = dwt3(X,'db1','mode','per'); wdec = wavedec3(X,1,'db1','mode','per'); max(abs((wdec.dec{4}(:)-dwtOut.dec{2,2,1}(:))))

ans = 0

max(abs((wdec.dec{5}(:)-dwtOut.dec{1,1,2}(:))))

ans = 0

### 3-D Wavelet Transform Using Specified Decomposition and Reconstruction Filters

Specify the decomposition and reconstruction filters as a cell array. Construct 8-by-8-by-8 matrix of integers 1 to 64 and make the data 3-D.

M = magic(8); X = repmat(M,[1 1 8]);

Obtain the 3-D discrete wavelet transform down to level 2 using the Daubechies extremal phase wavelet with two vanishing moments. Input the decomposition and reconstruction filters as a cell array. Use the periodic extension mode.

[LoD,HiD,LoR,HiR] = wfilters('db2'); wd2 = wavedec3(X,2,{LoD,HiD,LoR,HiR},'mode','per');

## Input Arguments

`x`

— Input data

3-D array

Input data, specified as a 3-D array.

**Data Types: **`double`

`n`

— Decomposition level

positive integer

Decomposition level, specified as a positive integer.
`wavedec3`

does not enforce a maximum level
restriction. See `wmaxlev`

.

**Data Types: **`double`

`wname`

— Analyzing wavelet

character vector | string scalar

Analyzing wavelet, specified as a character vector or string scalar.

**Note**

`wavedec3`

supports only Type 1 (orthogonal) or
Type 2 (biorthogonal) wavelets. See `wfilters`

for a
list of orthogonal and biorthogonal wavelets.

`extmode`

— Extension mode

`'zpd'`

| `'sp0'`

| `'spd'`

| ...

Extension mode used when performing the wavelet decomposition, 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'` ,
`'per'` | Periodized extension If the signal
length is odd and |

The global variable managed by `dwtmode`

specifies the
default extension mode. See `dwtmode`

for extension
mode descriptions.

`LoD,HiD`

— Wavelet decomposition filters

even-length real-valued vectors

Wavelet decomposition filters associated with an orthogonal or
biorthogonal wavelet, specified as even-length real-valued vectors.
`LoD`

is the lowpass decomposition filter, and
`HiD`

is the highpass decomposition filter. See
`wfilters`

for
details.

`LoR,HiR`

— Wavelet reconstruction filters

even-length real-valued vectors

Wavelet reconstruction filters associated with an orthogonal or
biorthogonal wavelet, specified as even-length real-valued vectors.
`LoR`

is the lowpass reconstruction filter, and
`HiR`

is the highpass reconstruction filter. See
`wfilters`

for
details.

## Output Arguments

`wdec`

— Wavelet output decomposition

structure

Wavelet output decomposition, returned as a structure with the following fields:

`sizeINI`

— Input data size

vector

Input data size, returned as a 1-by-3 vector.

`level`

— Level of the decomposition

integer

Level of the decomposition, returned as an integer.

`mode`

— Name of the wavelet transform extension mode

character vector

Name of the wavelet transform extension mode, returned as a character vector.

`filters`

— Wavelet filters

structure

Wavelet filters used for the decomposition, returned as a structure with the following fields:

`LoD`

— lowpass decomposition filter`HiD`

— highpass decomposition filter`LoR`

— lowpass decomposition filter`HiR`

— highpass decomposition filter

`dec`

— Decomposition coefficients

cell array

Decomposition coefficients, returned as an
*N*-by-1 cell array, where
*N* equals 7 `wdec.level`

+1.

`dec{1}`

contains the lowpass component
(approximation) at the level of the decomposition. The
approximation is equivalent to the filtering operations
`'LLL'`

.

`dec{k+2},...,dec{k+8}`

with ```
k =
0,7,14,...,7*(wdec.level-1)
```

contain the 3-D
wavelet coefficients for the multiresolution starting with the
coarsest level when `k=0`

.

For example, if `wdec.level=3`

,
`dec{2},...,dec{8}`

contain the wavelet
coefficients for level 3 (`k=0`

),
`dec{9},...,dec{15}`

contain the wavelet
coefficients for level 2 (`k=7`

), and
`dec{16},...,dec{22}`

contain the wavelet
coefficients for level 1
(`k=7*(wdec.level-1)`

).

At each level, the wavelet coefficients in
`dec{k+2},...,dec{k+8}`

are in the
following order:
`'HLL'`

,`'LHL'`

,`'HHL'`

,`'LLH'`

,`'HLH'`

,`'LHH'`

,`'HHH'`

.

The sequence of letters gives the order in which the separable
filtering operations are applied from left to right. For
example, `'LHH'`

means that the lowpass
(scaling) filter with downsampling is applied to the rows of
`x`

, followed by the highpass (wavelet)
filter with downsampling applied to the columns of
`x`

. Finally, the highpass filter with
downsampling is applied to the 3rd dimension of
`x`

.

`sizes`

— Successive sizes

matrix

Successive sizes of the decomposition components, returned as
an `n`

+1-by-2 matrix.

## Version History

**Introduced in R2010a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## 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)