Single-level discrete 2-D wavelet transform

`[`

computes the single-level 2-D DWT with the extension mode
`cA`

,`cH`

,`cV`

,`cD`

] = dwt2(___,'mode',`extmode`

)`extmode`

. Include this argument after all other
arguments.

**Note**

For `gpuArray`

inputs, the supported modes are
`'symh'`

(`'sym'`

) and
`'per'`

. All `'mode'`

options except
`'per'`

are converted to `'symh'`

. See
the example Single-Level 2-D Discrete Wavelet Transform on a GPU.

The 2-D wavelet decomposition algorithm for images is similar to the one-dimensional
case. The two-dimensional wavelet and scaling functions are obtained by taking the
tensor products of the one-dimensional wavelet and scaling functions. This kind of
two-dimensional DWT leads to a decomposition of approximation coefficients at level
*j* in four components: the approximation at level
*j* + 1, and the details in three orientations (horizontal,
vertical, and diagonal). The following chart describes the basic decomposition steps for
images.

where

— Downsample columns: keep the even-indexed columns

— Downsample rows: keep the even-indexed rows

— Convolve with filter

*X*the rows of the entry— Convolve with filter

*X*the columns of the entry

The decomposition is initialized by setting the approximation
coefficients equal to the image *s*: *cA*_{0} =
*s*.

**Note**

To deal with signal-end effects introduced by a convolution-based algorithm, the
1-D and 2-D DWT use a global variable managed by `dwtmode`

. This variable defines
the kind of signal extension mode used. The possible options include zero-padding
and symmetric extension, which is the default mode.

[1] Daubechies, Ingrid. *Ten Lectures on Wavelets*. CBMS-NSF
Regional Conference Series in Applied Mathematics 61. Philadelphia, Pa: Society for
Industrial and Applied Mathematics, 1992.

[2] Mallat, S.G. “A Theory for Multiresolution Signal Decomposition: The Wavelet
Representation.” *IEEE Transactions on Pattern Analysis and Machine
Intelligence* 11, no. 7 (July 1989): 674–93.
https://doi.org/10.1109/34.192463.

[3] Meyer, Y. *Wavelets and Operators*. Translated by D. H.
Salinger. Cambridge, UK: Cambridge University Press, 1995.