2D Discrete Wavelet Transform.
Parameters: | data : ndarray
wavelet : Wavelet object or name string
mode : str, optional
axes : 2-tuple of ints, optional
|
---|---|
Returns: | (cA, (cH, cV, cD)) : tuple
|
Examples
>>> import numpy as np
>>> import pywt
>>> data = np.ones((4,4), dtype=np.float64)
>>> coeffs = pywt.dwt2(data, 'haar')
>>> cA, (cH, cV, cD) = coeffs
>>> cA
array([[ 2., 2.],
[ 2., 2.]])
>>> cV
array([[ 0., 0.],
[ 0., 0.]])
The relation to the other common data layout where all the approximation and details coefficients are stored in one big 2D array is as follows:
------------------- | | | | cA(LL) | cH(LH) | | | | (cA, (cH, cV, cD)) <---> ------------------- | | | | cV(HL) | cD(HH) | | | | -------------------
PyWavelets does not follow this pattern because of pure practical reasons of simple access to particular type of the output coefficients.
2-D Inverse Discrete Wavelet Transform.
Reconstructs data from coefficient arrays.
Parameters: | coeffs : tuple
wavelet : Wavelet object or name string
mode : str, optional
axes : 2-tuple of ints, optional
|
---|
Examples
>>> import numpy as np
>>> import pywt
>>> data = np.array([[1,2], [3,4]], dtype=np.float64)
>>> coeffs = pywt.dwt2(data, 'haar')
>>> pywt.idwt2(coeffs, 'haar')
array([[ 1., 2.],
[ 3., 4.]])
Multilevel 2D Discrete Wavelet Transform.
Parameters: | data : ndarray
wavelet : Wavelet object or name string
mode : str, optional
level : int, optional
|
---|---|
Returns: | [cAn, (cHn, cVn, cDn), ... (cH1, cV1, cD1)] : list
|
Examples
>>> import pywt
>>> import numpy as np
>>> coeffs = pywt.wavedec2(np.ones((4,4)), 'db1')
>>> # Levels:
>>> len(coeffs)-1
2
>>> pywt.waverec2(coeffs, 'db1')
array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.]])
Multilevel 2D Inverse Discrete Wavelet Transform.
Returns: | 2D array of reconstructed data. : |
---|
Examples
>>> import pywt
>>> import numpy as np
>>> coeffs = pywt.wavedec2(np.ones((4,4)), 'db1')
>>> # Levels:
>>> len(coeffs)-1
2
>>> pywt.waverec2(coeffs, 'db1')
array([[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.],
[ 1., 1., 1., 1.]])