Reference

This is the class and function reference of pyrwt. Please refer to the tutorial for further details, as the class and function raw specifications may not be enough to give full guidelines on their uses.

rwt.dwt()

Computes the discrete wavelet transform y for a 1D or 2D input signal x using the scaling filter h0 and wavelet filter h1.

Parameters :

x : array-like, shape = [n] or [m, n]

Finite length 1D or 2D signal (implicitly periodized)

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

L : integer, optional (default=None)

Number of levels. In the case of a 1D signal, length(x) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L. If no argument is specified, a full DWT is returned for maximal possible L.

Returns :

y : array-like, shape = [n] or [m, n]

The wavelet transform of the signal (see example to understand the coefficients)

L : integer

number of decomposition levels

See also

idwt, rdwt, irdwt

Examples

2D Example:

>>> from scipy.misc import lena
>>> from rwt import dwt, idwt
>>> from rwt.utilities import makeSignal
>>> from rwt.wavelets import daubcqf
>>> img = lena()
>>> h0, h1 = daubcqf(4, 'min')
>>> L = 1
>>> y, L = dwt(img, h0, h1, L)
rwt.idwt()

Computes the inverse discrete wavelet transform x for a 1D or 2D input signal y using the scaling filter h0 and wavelet filter h1.

Parameters :

y : array-like, shape = [n] or [m, n]

Finite length 1D or 2D input signal (implicitly periodized) (see function mdwt to find the structure of y)

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

L : integer, optional (default=None)

Number of levels. In the case of a 1D signal, len(x) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L. If no argument is specified, a full DWT is returned for maximal possible L.

Returns :

x : array-like, shape = [n] or [m, n]

Periodic reconstructed signal

L : integer

Number of decomposition levels

See also

dwt, rdwt, irdwt

Examples

1D Example:

>>> from rwt import dwt, idwt
>>> from rwt.utilities import makeSignal
>>> from rwt.wavelets import daubcqf
>>> xin = makeSignal('LinChirp', 8)
>>> h0, h1 = daubcqf(4, 'min')
>>> L = 1
>>> y, L = dwt(xin, h0, h1, L)
>>> print y
[0.1912, 0.8821, 1.4257, 0.3101, -0.0339, 0.1001, 0.2201, 0.0000]
>>> x, L = idwt(y, h, L)
>>> print x
[0.0491, 0.1951, 0.4276, 0.7071, 0.9415, 0.9808, 0.6716, 0.0000]
rwt.rdwt()

Computes the redundant discrete wavelet transform y for a 1D or 2D input signal. (Redundant means here that the sub-sampling after each stage is omitted.) yl contains the lowpass and yh the highpass components. In the case of a 2D signal, the ordering in yh is [lh hl hh lh hl ... ] (first letter refers to row, second to column filtering).

Parameters :

x : array-like, shape = [n] or [m, n]

Finite length 1D or 2D signal (implicitly periodized)

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

L : integer, optional (default=None)

Number of levels. In the case of a 1D signal, len(x) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L. If no argument is specified, a full DWT is returned for maximal possible L.

Returns :

yl : array-like, shape = [n] or [m, n]

Lowpass component

yh : array-like, shape = [n] or [m, n]

Highpass component

L : integer

number of decomposition levels

Warning

min(x.shape)/2**L should be greater than len(h)

See also

dwt, idwt, irdwt

rwt.irdwt()

Computes the inverse redundant discrete wavelet transform x for a 1D or 2D input signal. (Redundant means here that the sub-sampling after each stage of the forward transform has been omitted.) yl contains the lowpass and yl the highpass components as computed, e.g., by mrdwt. In the case of a 2D signal, the ordering in yh is [lh hl hh lh hl ... ] (first letter refers to row, second to column filtering).

Parameters :

yl : array-like, shape = [n] or [m, n]

Lowpass component

yh : array-like, shape = [n] or [m, n]

Highpass component

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

L : integer

number of levels. In the case of a 1D signal, len(yl) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L.

Returns :

x : array-like, shape = [n] or [m, n]

Finite length 1D or 2D signal

L : integer

number of decomposition levels

Warning

min(yl.shape)/2**L should be greater than len(h)

See also

dwt, idwt, rdwt

rwt.dwtaxis()

Computes the discrete wavelet transform over signal x along a specified axis using the scaling filter h0, and wavelet filter h1.

Parameters :

x : array-like, shape = Arbitrary dimension

Input signal

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

axis : integer, optional (default=0)

The axis of x for which to perform the transform.

L : integer, optional (default=None)

Number of levels. In the case of a 1D signal, length(x) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L. If no argument is specified, a full DWT is returned for maximal possible L.

Returns :

y : array-like, shape = Same dimension of x.

The wavelet transform of the input signal

L : integer

number of decomposition levels

See also

idwt, rdwt, irdwt, idwtaxis

rwt.idwtaxis()

Computes the inverse discrete wavelet transform over signal x along a specified axis using the scaling filter h0, and wavelet filter h1.

Parameters :

y : array-like, shape = Arbitrary dimension

Input signal

h0 : array-like, shape = [n]

Scaling filter

h1 : array-like, shape = [n]

Wavelet filter

axis : integer, optional (default=0)

The axis of x for which to perform the transform.

L : integer, optional (default=None)

Number of levels. In the case of a 1D signal, length(x) must be divisible by 2**L; in the case of a 2D signal, the row and the column dimension must be divisible by 2**L. If no argument is specified, a full DWT is returned for maximal possible L.

Returns :

x : array-like, shape = Same dimension of x.

The inverse wavelet transform of the input signal

L : integer

number of decomposition levels

See also

idwt, rdwt, irdwt, dwtaxis

utilities - Several utilities useful when using pyrwt

rwt.utilities.hardThreshold(y, thld)[source]

Hard thresholds the input signal y with the threshold value thld.

Parameters :

y : array-like, shape = Arbitrary dimension

Finite length signal (implicitly periodized)

thld : float

Value by which to threshold the input signal

Returns :

x : array-like, shape = Same dimension of y

Hard thresholded output x = (abs(y)>thld)*y

See also

softThreshold

Examples

>>> from rwt.utilities import makeSignal, hardThreshold
>>> y = makeSignal('WernerSorrows', 8)
>>> print hardThreshold(y, thld=1)
[1.5545, 5.3175, 0, 1.6956, -1.2678, 0, 1.7332, 0]
rwt.utilities.softThreshold(y, thld)[source]

Soft thresholds the input signal y with the threshold value thld.

Parameters :

y : array-like, shape = Arbitrary dimension

Finite length signal (implicitly periodized)

thld : float

Value by which to threshold the input signal

Returns :

x : array-like, shape = Same dimension as y

Soft thresholded output x = sign(y)(abs(y)-thld)_+

See also

hardThreshold

Examples

>>> from rwt.utilities import makeSignal, hardThreshold
>>> y = makeSignal('Doppler', 8)
>>> print softThreshold(y, thld=0.2)
[0, 0, 0, -0.0703, 0, 0.2001, 0.0483, 0]
rwt.utilities.makeSignal(signal_name='AllSig', N=512)[source]

Creates artificial test signal identical to the standard test signals proposed and used by D. Donoho and I. Johnstone in WaveLab (- a matlab toolbox developed by Donoho et al. the statistics department at Stanford University).

Parameters :

signal_name : string, optional (default=’AllSig’)

Name of the desired signal. Supported values:
  • ‘AllSig’ (Returns a list with all the signals)
  • ‘HeaviSine’
  • ‘Bumps’
  • ‘Blocks’
  • ‘Doppler’
  • ‘Ramp’
  • ‘Cusp’
  • ‘Sing’
  • ‘HiSine’
  • ‘LoSine’
  • ‘LinChirp’
  • ‘TwoChirp’
  • ‘QuadChirp’
  • ‘MishMash’
  • ‘Werner Sorrows’ (Heisenberg)
  • ‘Leopold’ (Kronecker)

N : integer, optional (default=512)

Length in samples of the desired signal

Returns :

x : array/list of arrays, shape = [N]

References

WaveLab can be accessed at www_url: http://playfair.stanford.edu/~wavelab/ Also see various articles by D.L. Donoho et al. at web_url: http://playfair.stanford.edu/

Table Of Contents

Previous topic

Wavelets Reference

Next topic

License for pyrwt

This Page