PyWavelets documentation has moved to pywavelets.readthedocs.io. You will be automatically redirected there in 10 seconds.
Inverse Discrete Wavelet Transform (IDWT)¶
Single level idwt
¶
-
pywt.
idwt
(cA, cD, wavelet, mode='symmetric', axis=-1)¶ Single level Inverse Discrete Wavelet Transform.
Parameters: cA : array_like or None
Approximation coefficients. If None, will be set to array of zeros with same shape as cD.
cD : array_like or None
Detail coefficients. If None, will be set to array of zeros with same shape as cA.
wavelet : Wavelet object or name
Wavelet to use
mode : str, optional (default: ‘symmetric’)
Signal extension mode, see Modes
axis: int, optional
Axis over which to compute the inverse DWT. If not given, the last axis is used.
Returns: rec: array_like
Single level reconstruction of signal from given coefficients.
Example:
>>> import pywt >>> (cA, cD) = pywt.dwt([1,2,3,4,5,6], 'db2', 'smooth') >>> print pywt.idwt(cA, cD, 'db2', 'smooth') array([ 1., 2., 3., 4., 5., 6.])
One of the neat features of
idwt()
is that one of the cA and cD arguments can be set toNone
. In that situation the reconstruction will be performed using only the other one. Mathematically speaking, this is equivalent to passing a zero-filled array as one of the arguments.Example:
>>> import pywt >>> (cA, cD) = pywt.dwt([1,2,3,4,5,6], 'db2', 'smooth') >>> A = pywt.idwt(cA, None, 'db2', 'smooth') >>> D = pywt.idwt(None, cD, 'db2', 'smooth') >>> print A + D array([ 1., 2., 3., 4., 5., 6.])
Multilevel reconstruction using waverec
¶
-
pywt.
waverec
(coeffs, wavelet, mode='symmetric')¶ Multilevel 1D Inverse Discrete Wavelet Transform.
Parameters: coeffs : array_like
Coefficients list [cAn, cDn, cDn-1, ..., cD2, cD1]
wavelet : Wavelet object or name string
Wavelet to use
mode : str, optional
Signal extension mode, see Modes (default: ‘symmetric’)
Examples
>>> import pywt >>> coeffs = pywt.wavedec([1,2,3,4,5,6,7,8], 'db1', level=2) >>> pywt.waverec(coeffs, 'db1') array([ 1., 2., 3., 4., 5., 6., 7., 8.])
Direct reconstruction with upcoef
¶
-
pywt.
upcoef
(part, coeffs, wavelet, level=1, take=0)¶ Direct reconstruction from coefficients.
Parameters: part : str
Coefficients type: * ‘a’ - approximations reconstruction is performed * ‘d’ - details reconstruction is performed
coeffs : array_like
Coefficients array to recontruct
wavelet : Wavelet object or name
Wavelet to use
level : int, optional
Multilevel reconstruction level. Default is 1.
take : int, optional
Take central part of length equal to ‘take’ from the result. Default is 0.
Returns: rec : ndarray
1-D array with reconstructed data from coefficients.
See also
Examples
>>> import pywt >>> data = [1,2,3,4,5,6] >>> (cA, cD) = pywt.dwt(data, 'db2', 'smooth') >>> pywt.upcoef('a', cA, 'db2') + pywt.upcoef('d', cD, 'db2') array([-0.25 , -0.4330127 , 1. , 2. , 3. , 4. , 5. , 6. , 1.78589838, -1.03108891]) >>> n = len(data) >>> pywt.upcoef('a', cA, 'db2', take=n) + pywt.upcoef('d', cD, 'db2', take=n) array([ 1., 2., 3., 4., 5., 6.])