The WV_DWT function returns the multi-dimensional discrete wavelet transform of the input Array. The transform is done by WV_PWT using a user-inputted wavelet filter.

The length of each dimension of Array must be either a power of two (2), or must be less than four (4). The transform is not computed over dimensions of lengths less than four (4), but is computed over all other dimensions (for example, the wavelet transform of an array of size [3, 256] is computed over each [1, 256] column vector).

Example


The following example shows how to compute the first three levels of the pyramid algorithm using either the N_LEVELS keyword or WV_PWT:

 

; Construct a random vector.
n = 1024
x = randomn(s,n)
info = WV_FN_DAUBECHIES(2, wavelet, scaling, ioff, joff)
 
; Take the wavelet transform but stop at level 3.
wv_dwtpartial = WV_DWT(x, wavelet, scaling, ioff, joff, $
   N_LEVELS=3)
 
; First level of the pyramid algorithm.
wv_level1 = WV_PWT(x, wavelet, scaling, ioff, joff)
w_scaling1 = wv_level1[0:n/2-1]  ; Left (scaling) half
w_wavelet1 = wv_level1[n/2:*]    ; Right (wavelet) half
 
; Second level of the pyramid algorithm.
wv_level2 = WV_PWT(w_scaling1, wavelet, scaling, ioff, joff)
w_scaling2 = wv_level2[0:n/4-1]  ; Left (scaling) half
w_wavelet2 = wv_level2[n/4:*]    ; Right (wavelet) half
 
; Third level of the pyramid algorithm.
wv_level3 = WV_PWT(w_scaling2, wavelet, scaling, ioff, joff)
 
; Verify that using WV_DWT with N_LEVELS=3
; is the same as calling WV_PWT three times.
wv_partial123 = [wv_level3, w_wavelet2, w_wavelet1]
 
print, MAX(ABS(wv_dwtpartial - wv_partial123))

IDL prints:

    0.000000

Syntax


Result = WV_DWT(Array, Scaling, Wavelet, Ioff, Joff [, /DOUBLE] [, /INVERSE] [, N_LEVELS=value])

Return Value


The result is an output array of the same dimensions as Array, containing the discrete wavelet transform over each dimension.

Arguments


Array

The input vector or array. The length of each dimension must be either less than four (4) or a power of two (2).

Scaling

A vector of scaling (father) coefficients, of length N.

Wavelet

A vector of wavelet (mother) coefficients, of length N.

Ioff

An integer that specifies the support offset for Scaling. To center the scaling function over each point in Array, set Ioff to –N/2+2.

Joff

An integer that specifies the support offset for Wavelet. To center the wavelet function over each point in Array, set Joff to –N/2+2.

Keywords


DOUBLE

Set this keyword to force the computation to be done in double-precision arithmetic.

INVERSE

If set, the inverse transform is computed. By default, the forward transform is computed.

N_LEVELS

Set this keyword to the number of wavelet levels to compute in the pyramid algorithm, starting with the smallest wavelet scale and progressing to larger scales. If this keyword is not set or is set to zero, then all wavelet levels in the pyramid algorithm are computed.

Method and Result Format


The WV_DWT function computes the wavelet coefficients using the pyramidal algorithm (Mallat 1989).

One-Dimensional Vector

For a one-dimensional vector, the pyramid appears below:

Array elements
0,  1,  2,  3,  4,  5,  6,  7,  8,  9101112131415]
   \ /     \ /     \ /     \ /     \ /     \ /     \ /     \ /
  s0,d0   s1,d1   s2,d2   s3,d3   s4,d4   s5,d5   s6,d6   s7,d7
     \    /          \    /          \    /          \    /
       \ /             \ /             \ /             \ /
       S0,D0         S1,D1             S2,D2         S3,D3
          \         /                     \         /
            \     /                         \     /
              \ /                             \ /
             S0,D0                           S1,D1

At each level of the hierarchy, the WV_PWT function is used to compute the scaling coefficient Si and wavelet coefficient Di (where i represents the position). The letters s, S, S and d, D, D represent increasing scale. The wavelet coefficients are stored in Result in order from largest scales to smallest:

Result = [ S0S1,  D0D1,  D0, D1, D2, D3,
  d0, d1, d2, d3, d4, d5, d6, d7 ]

Two-Dimensional Array

For a two-dimensional Array, the wavelet transform is computed using the pyramidal algorithm along each dimension. The wavelet coefficients are stored in order with the largest scales in the [0, 0] position. As an example, for an 8 x 8 Array, the Result is an 8 x 8 array with the following structure:

[0,0]
 [[ A0B0  A1B0    C0B0  C1B0    c0B0  c1B0  c2B0  c3B0 ],
  [ A0B1  A1B1    C0B1  C1B1    c0B1  c1B1  c2B1  c3B1 ],
 
  [ A0D0  A1D0    C0D0  C1D0    c0D0  c1D0  c2D0  c3D0 ],
  [ A0D1  A1D1    C0D1  C1D1    c0D1  c1D1  c2D1  c3D1 ],
 
  [ A0d0  A1d0    C0d0  C1d0    c0d0  c1d0  c2d0  c3d0 ],
  [ A0d1  A1d1    C0d1  C1d1    c0d1  c1d1  c2d1  c3d1 ],
  [ A0d2  A1d2    C0d2  C1d2    c0d2  c1d2  c2d2  c3d2 ],
  [ A0d3  A1d3    C0d3  C1d3    c0d3  c1d3  c2d3  c3d3 ]]

Here A and B represent the scale coefficients for the first and second dimensions, respectively, The C and D represent the largest-scale wavelet coefficients for the first and second dimensions, respectively, while c and d represent the small-scale wavelet coefficients. Subscripts 0, 1, 2, 3 denote the position of the wavelet within the image.

Version History


5.3

Introduced

6.1

Added N_LEVELS keyword

Resources and References


WV_DWT is based on the routine wtn described in section 13.10 of Numerical Recipes in C: The Art of Scientific Computing, 2nd ed. (Cambridge University Press), and is used by permission.

See Also


WV_CWT, WV_PWT, WTN