This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

dwt2

Single-level discrete 2-D wavelet transform

dwt2 computes the single-level 2-D wavelet decomposition. Compare dwt2 with wavedec2 which may be more useful for your application. The decomposition is done with respect to either a particular wavelet (see wfilters for more information) or particular wavelet decomposition filters.

Syntax

[cA,cH,cV,cD] = dwt2(X,wname)
[cA,cH,cV,cD] = dwt2(X,LoD,HiD)
[cA,cH,cV,cD] = dwt2(___,'mode',extmode)

Description

example

[cA,cH,cV,cD] = dwt2(X,wname) computes the single-level 2-D discrete wavelet transform (DWT) of the input data X using the wname wavelet. dwt2 returns the approximation coefficients matrix cA and detail coefficients matrices cH, cV, and cD (horizontal, vertical, and diagonal, respectively).

example

[cA,cH,cV,cD] = dwt2(X,LoD,HiD) computes the single-level 2-D DWT using the wavelet decomposition lowpass filter LoD and highpass filter HiD. The decomposition filters must have the same length.

[cA,cH,cV,cD] = dwt2(___,'mode',extmode) computes the single-level 2-D DWT with the extension mode extmode. Include this argument after all other arguments.

Examples

collapse all

Load and display an image.

load woman
imagesc(X)
colormap(map)

Obtain the single-level 2-D discrete wavelet transform of the image using the order 4 symlet and periodic extension.

[cA,cH,cV,cD] = dwt2(X,'sym4','mode','per');

Display the vertical detail coefficients and the approximation coefficients.

imagesc(cV)
title('Vertical Detail Coefficients')

imagesc(cA)
title('Approximation Coefficients')

Load and display an image.

load sculpture
imagesc(X)
colormap gray

Generate the lowpass and highpass decomposition filters for the Haar wavelet.

[LoD,HiD] = wfilters('haar','d');

Use the filters to perform a single-level 2-D wavelet decomposition. Use half-point symmetric extension. Display the approximation and detail coefficients.

[cA,cH,cV,cD] = dwt2(X,LoD,HiD,'mode','symh');
subplot(2,2,1)
imagesc(cA)
colormap gray
title('Approximation')
subplot(2,2,2)
imagesc(cH)
colormap gray
title('Horizontal')
subplot(2,2,3)
imagesc(cV)
colormap gray
title('Vertical')
subplot(2,2,4)
imagesc(cD)
colormap gray
title('Diagonal')

Input Arguments

collapse all

Input data, specified as an m-by-n matrix representing an indexed image or an m-by-n-by-3 array representing a truecolor image. For more information on truecolor images, see RGB (Truecolor) Images (MATLAB).

Data Types: double

Analyzing wavelet used to compute the 2-D DWT, specified as a character vector or string scalar. The analyzing wavelet is from one of the following wavelet families: Daubechies, Coiflets, Symlets, Fejér-Korovkin, Discrete Meyer, Biorthogonal, and Reverse Biorthogonal. See wfilters for the wavelets available in each family.

Wavelet decomposition lowpass filter, specified as an even-length real-valued vector. LoD must be of the same length as HiD.

Wavelet decomposition highpass filter, specified as an even-length real-valued vector. HiD must be of the same length as LoD.

Extension mode used when performing the DWT, 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'

Periodized extension (1)

'per'

Periodized extension (2)

If the signal length is odd, wextend adds to the right an extra sample that is equal to the last value, and performs the extension using the 'ppd' mode. Otherwise, 'per' reduces to 'ppd'. This rule also applies to images.

The global variable managed by dwtmode specifies the default extension mode.

Example: [cA,cH,cV,cD] = dwt2(x,'db4','mode','symw');

Output Arguments

collapse all

Approximation coefficients, returned as an array whose size depends on X. Let sx = size(X) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, then this output is of size ceil(sx/2).

  • For the other extension modes, this output is of size floor((sx+lf-1)/2).

Data Types: double

Horizontal detail coefficients, returned as an array whose size depends on X. Let sx = size(X) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, then this output is of size ceil(sx/2).

  • For the other extension modes, this output is of size floor((sx+lf-1)/2).

Data Types: double

Vertical detail coefficients, returned as an array whose size depends on X. Let sx = size(X) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, then this output is of size ceil(sx/2).

  • For the other extension modes, this output is of size floor((sx+lf-1)/2).

Data Types: double

Diagonal detail coefficients, returned as an array whose size depends on X. Let sx = size(X) and lf = the length of the decomposition filters.

  • If the DWT extension mode is set to periodization, then this output is of size ceil(sx/2).

  • For the other extension modes, this output is of size floor((sx+lf-1)/2).

Data Types: double

Algorithms

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.

  • — 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: CA0=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.

References

[1] Daubechies, I. Ten Lectures on Wavelets, CBMS-NSF Regional Conference Series in Applied Mathematics. Philadelphia, PA: SIAM Ed, 1992.

[2] Mallat, S. G. “A Theory for Multiresolution Signal Decomposition: The Wavelet Representation,” IEEE Transactions on Pattern Analysis and Machine Intelligence. Vol. 11, Issue 7, July 1989, pp. 674–693.

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

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a