Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# cfs2wpt

Wavelet packet tree construction from coefficients

## Description

CFS2WPT builds a wavelet packet tree (T) and the related analyzed signal or image (X) using the following input information:

WNAME: name of the wavelet used for the analysis

SIZE_OF_DATA: size of the analyzed signal or image

TN_OF_TREE: vector containing the terminal node indices of the tree

ORDER: 2 for a signal or 4 for an image

CFS: coefficients used to reconstruct the original signal or image. CFS is optional. When CFS2WPT is used without the CFS input parameter, the wavelet packet tree structure (T) is generated, but all the tree coefficients are null (including X).

## Build Wavelet Packet Tree

This example shows how to build a wavelet packet tree in two ways: 1.) By filling the wavelet packet tree with coefficients, and 2.) By creating the wavelet packet tree and using write

Load an image and obtain the wavelet packet decomposition down to level 2 with the 'sym4' wavelet.

```load detail;
imagesc(X); colormap gray; title('Original Image');
Tr = wpdec2(X,2,'sym4');
```

Read the coefficients from the wavelet packet tree. Add noise to the coefficients and plot the new wavelet packet tree.

```cfs = read(Tr,'allcfs');
noisyCfs = cfs + 40*rand(size(cfs));
noisyT = cfs2wpt('sym4',size(X),tnodes(Tr),4,noisyCfs);
plot(noisyT)
```

To illustrate building a wavelet packet tree using write, construct an admissible binary wavelet packet tree with terminal nodes [2 3 9 10]. The analyzing wavelet is 'sym4' and the signal length is 1024.

```tr = cfs2wpt('sym4',[1 1024],[2 3 9 10]',2);
```

Fill terminal nodes [3 9] with coefficients.

```sN = read(tr,'sizes',[3,9]);
sN3 = sN(1,:); sN9 = sN(2,:);
cfsN3 = randn(sN3);
cfsN9 = randn(sN9);
tr = write(tr,'cfs',3,cfsN3,'cfs',9,cfsN9);
```

Plot the resulting wavelet packet tree and synthesized signal.

```plot(tr)
```