Discrete Wavelet Transform
Wraps GSL's gsl_wavelet_transform_forward(), and gsl_wavelet_transform_inverse() and creates plot methods.
AUTHOR:
This function initializes an GSLDoubleArray of length n which can perform a discrete wavelet transform.
INPUT:
For daubechies wavelets, wavelet_k specifies a daubechie wavelet
with vanishing moments.
for
even are the
only ones implemented.
For Haar wavelets, wavelet_k must be 2.
For bspline wavelets, wavelet_k of will give biorthogonal B-spline wavelets of order
where wavelet_k is
.
The wavelet transform uses
levels.
OUTPUT:
An array of the form
for
the detail coefficients of level
.
The centered forms align the coefficients of the sub-bands on edges.
EXAMPLES:
sage: a = WaveletTransform(128,'daubechies',4)
sage: for i in range(1, 11):
... a[i] = 1
... a[128-i] = 1
sage: a.plot().show(ymin=0)
sage: a.forward_transform()
sage: a.plot().show()
sage: a = WaveletTransform(128,'haar',2)
sage: for i in range(1, 11): a[i] = 1; a[128-i] = 1
sage: a.forward_transform()
sage: a.plot().show(ymin=0)
sage: a = WaveletTransform(128,'bspline_centered',103)
sage: for i in range(1, 11): a[i] = 1; a[100+i] = 1
sage: a.forward_transform()
sage: a.plot().show(ymin=0)
This example gives a simple example of wavelet compression:
sage: a = DWT(2048,'daubechies',6)
sage: for i in range(2048): a[i]=float(sin((i*5/2048)**2))
sage: a.plot().show() # long time (7s on sage.math, 2011)
sage: a.forward_transform()
sage: for i in range(1800): a[2048-i-1] = 0
sage: a.backward_transform()
sage: a.plot().show() # long time (7s on sage.math, 2011)
Bases: sage.gsl.gsl_array.GSLDoubleArray
Discrete wavelet transform class.
This function initializes an GSLDoubleArray of length n which can perform a discrete wavelet transform.
INPUT:
For daubechies wavelets, wavelet_k specifies a daubechie wavelet
with vanishing moments.
for
even are the
only ones implemented.
For Haar wavelets, wavelet_k must be 2.
For bspline wavelets, wavelet_k of will give biorthogonal B-spline wavelets of order
where wavelet_k is
.
The wavelet transform uses
levels.
OUTPUT:
An array of the form
for
the detail coefficients of level
.
The centered forms align the coefficients of the sub-bands on edges.
EXAMPLES:
sage: a = WaveletTransform(128,'daubechies',4)
sage: for i in range(1, 11):
... a[i] = 1
... a[128-i] = 1
sage: a.plot().show(ymin=0)
sage: a.forward_transform()
sage: a.plot().show()
sage: a = WaveletTransform(128,'haar',2)
sage: for i in range(1, 11): a[i] = 1; a[128-i] = 1
sage: a.forward_transform()
sage: a.plot().show(ymin=0)
sage: a = WaveletTransform(128,'bspline_centered',103)
sage: for i in range(1, 11): a[i] = 1; a[100+i] = 1
sage: a.forward_transform()
sage: a.plot().show(ymin=0)
This example gives a simple example of wavelet compression:
sage: a = DWT(2048,'daubechies',6)
sage: for i in range(2048): a[i]=float(sin((i*5/2048)**2))
sage: a.plot().show() # long time (7s on sage.math, 2011)
sage: a.forward_transform()
sage: for i in range(1800): a[2048-i-1] = 0
sage: a.backward_transform()
sage: a.plot().show() # long time (7s on sage.math, 2011)