# upwlev2

Single-level reconstruction of 2-D wavelet decomposition

## Syntax

``[nc,ns,ca] = upwlev2(c,s,wname)``
``[nc,ns,ca] = upwlev2(c,s,LoR,HiR)``

## Description

````[nc,ns,ca] = upwlev2(c,s,wname)` performs the single-level reconstruction of the wavelet decomposition structure [`c`,`s`] using the wavelet specified by `wname`, giving the new structure [`nc`,`ns`], and extracts the last approximation coefficients matrix `ca`.```

example

````[nc,ns,ca] = upwlev2(c,s,LoR,HiR)` performs the single-level reconstruction using the specified lowpass and highpass wavelet reconstruction filters `LoR` and `HiR`, respectively.```

## Examples

collapse all

```load porche image(X) colormap(map)```

Save the current extension mode, and set the extension mode to zero-padding.

```origmode = dwtmode("status","nodisp"); dwtmode("zpd","nodisp")```

Obtain the DWT decomposition of the image down to level 2. Use the Haar wavelet.

```wv = "haar"; [c,s] = wavedec2(X,2,wv); size(c)```
```ans = 1×2 1 262144 ```
`s`
```s = 4×2 128 128 128 128 256 256 512 512 ```

Use the `appcoef2` function to extract the approximation coefficients from the wavelet decomposition structure [`c`,`s`].

```a = appcoef2(c,s,wv); size(a)```
```ans = 1×2 128 128 ```

Perform the single-level reconstruction of the wavelet decomposition structure [`c`,`s`]. Also obtain the approximation matrix at level 2. Confirm the total number of coefficients has not changed, and the approximation coefficients obtained using `appcoef2` and `upwlev2` are equal.

```[nc,ns,ca] = upwlev2(c,s,wv); size(nc)```
```ans = 1×2 1 262144 ```
`ns`
```ns = 3×2 256 256 256 256 512 512 ```
`max(max(abs(a-ca)))`
```ans = 0 ```

Restore the original extension mode.

`dwtmode(origmode,"nodisp")`

## Input Arguments

collapse all

Wavelet decomposition vector, specified as a real-valued vector. The vector `c` contains the approximation and detail coefficients organized by level. The bookkeeping matrix `s` is used to parse `c`. `c` and `s` are outputs of `wavedec2`.

Data Types: `double`

Bookkeeping matrix, specified as an integer-valued matrix. The matrix `s` contains the dimensions of the wavelet coefficients by level and is used to parse the wavelet decomposition vector `c`. `c` and `s` are outputs of `wavedec2`.

Data Types: `double`

Analyzing wavelet, specified as a character vector or string scalar. `wname` must specify the same wavelet used to obtain the original wavelet decomposition structure `[c,s]`. The `wavedec2` function supports only orthogonal and biorthogonal wavelets. See `wfilters` for a list of orthogonal and biorthogonal wavelets.

Data Types: `char` | `string`

Wavelet reconstruction filters, specified as a pair of even-length real-valued vectors. `LoR` is the lowpass reconstruction filter, and `HiR` is the highpass reconstruction filter. `LoR` and `HiR` must correspond to the wavelet used to obtain the original wavelet decomposition structure `[c,s]`. The lengths of `LoR` and `HiR` must be equal. See `wfilters` for a list of orthogonal and biorthogonal wavelets.

Data Types: `double`

## Output Arguments

collapse all

Wavelet decomposition, returned as a vector. The vector contains the wavelet coefficients. `[c,s]` is a decomposition at level `n = size(s,1)-2`, so `[nc,ns]` is the same decomposition at level n-1. The bookkeeping matrix `ns` contains the contains the dimensions of the wavelet coefficients by level and is used to parse the wavelet decomposition vector `nc`.

Data Types: `double`

Bookkeeping matrix, returned as a matrix of positive integers. The bookkeeping matrix is used to parse the coefficients in the wavelet decomposition `nc` by level.

Data Types: `double`

Approximation matrix at level n, where ```n = size(s,1)-2```.

If `c` and `s` are obtained from an indexed image analysis or a truecolor image analysis, `ca` is an m-by-n matrix or an m-by-n-by-3 array, respectively. For more information, see `wavedec2`.

For more information on image formats, see `image` and `imfinfo`.

Data Types: `double`

## Version History

Introduced before R2006a