Main Content

dwtmode

Discrete wavelet transform extension mode

Description

example

dwtmode(mode) sets the signal or image extension mode for both discrete wavelet and wavelet packet transforms to mode. All functions and Wavelet Analyzer app tools involving either the discrete wavelet transform (1-D and 2-D) or wavelet packet transform (1-D and 2-D), use the specified DWT extension mode.

The extension modes provide options for dealing with the problem of border distortion in signal or image analysis. For more information, see Border Effects.

Note

Functions involving the discrete wavelet transform may not use the current extension mode for gpuArray input. Such cases are documented on the function reference page.

dwtmode or dwtmode('status') display the current mode. If DWTMODE.DEF exists in the current path, the default mode is loaded from DWTMODE.DEF at the start of the MATLAB® session. Otherwise, the file DWTMODE.CFG is used.

st = dwtmode or st = dwtmode('status') display and return the current mode in st.

st = dwtmode('status','nodisp') returns the current mode st and no status or warning text is displayed in the MATLAB command window.

dwtmode('save',mode) saves mode as the new default mode to the file DWTMODE.DEF in the current folder. If DWTMODE.DEF already exists in the current folder, the file is overwritten. The new default mode will be active as the default mode in the next MATLAB session.

Note

To execute in parallel any functionality that depends on the extension mode, either save the extension mode using dwtmode('save',mode) before running your parfor loop, or call dwtmode(mode) inside your parfor loop.

Changing the extension mode in a MATLAB session does not have the desired effect if anything dependent on that mode is called in parallel. In a parallel environment, each worker has its own MATLAB execution engine, and each worker respects the DWTMODE.CFG file, but not an override in the current session. Therefore, to run in parallel, the extension mode must either be saved to the current folder, or the extension mode must be set for each worker.

Executing for-loop iterations in parallel requires Parallel Computing Toolbox™. For more information, see parfor (Parallel Computing Toolbox).

dwtmode('save') is equivalent to dwtmode('save',CURRENTMODE), where CURRENTMODE represents the current extension mode.

Examples

collapse all

Display the current DWT signal extension mode. If the DWT extension mode global variable does not exist, the default is half-point symmetrization.

dwtmode
                                                       
*******************************************************
**  DWT Extension Mode: Symmetrization (half-point)  **
*******************************************************
                                                       

Save the current extension mode. Change the extension mode to periodized extension.

origmode = dwtmode('status','nodisplay');
dwtmode('per','nodisplay')

Display the current DWT signal extension mode.

dwtmode
                                         
*****************************************
**  DWT Extension Mode: Periodization  **
*****************************************
                                         

Restore the original extension mode.

dwtmode(origmode,'nodisplay')
dwtmode
                                                       
*******************************************************
**  DWT Extension Mode: Symmetrization (half-point)  **
*******************************************************
                                                       

Input Arguments

collapse all

DWT extension mode used to extend the input, specified as one of the following values.

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 mode is 'per', an extra sample equal to the last value is added to the right and the extension is performed in 'ppd' mode. If the signal length is even, 'per' is equivalent to 'ppd'. This rule also applies to images.

The DWT associated with the symmetric, smooth, zero, and periodic extension modes are slightly redundant. But the inverse DWT ensures a perfect reconstruction for the extensions mentioned.

Note

dwtmode updates a global variable. Only use dwtmode to change the extension mode. Avoid changing the global variable directly.

Output Arguments

collapse all

DWT extension mode, returned as a character array.

Tips

  • For most wavelet applications, either a periodic extension or symmetric extension works fine.

References

[1] Strang, G., and T. Nguyen. Wavelets and Filter Banks. Wellesley, MA: Wellesley-Cambridge Press, 1996.

See Also

Apps

Functions

Introduced before R2006a