2-D Inverse Discrete Wavelet Transform. Reconstructs data from coefficient arrays. Parameters ---------- coeffs : tuple (cA, (cH, cV, cD)) A tuple with approximation coefficients and three details coefficients 2D arrays like from ``dwt2``. If any of these
(coeffs, wavelet, mode='symmetric', axes=(-2, -1))
| 73 | |
| 74 | |
| 75 | def idwt2(coeffs, wavelet, mode='symmetric', axes=(-2, -1)): |
| 76 | """ |
| 77 | 2-D Inverse Discrete Wavelet Transform. |
| 78 | |
| 79 | Reconstructs data from coefficient arrays. |
| 80 | |
| 81 | Parameters |
| 82 | ---------- |
| 83 | coeffs : tuple |
| 84 | (cA, (cH, cV, cD)) A tuple with approximation coefficients and three |
| 85 | details coefficients 2D arrays like from ``dwt2``. If any of these |
| 86 | components are set to ``None``, it will be treated as zeros. |
| 87 | wavelet : Wavelet object or name string, or 2-tuple of wavelets |
| 88 | Wavelet to use. This can also be a tuple containing a wavelet to |
| 89 | apply along each axis in ``axes``. |
| 90 | mode : str or 2-tuple of strings, optional |
| 91 | Signal extension mode, see :ref:`Modes <ref-modes>`. This can |
| 92 | also be a tuple of modes specifying the mode to use on each axis in |
| 93 | ``axes``. |
| 94 | axes : 2-tuple of ints, optional |
| 95 | Axes over which to compute the IDWT. Repeated elements mean the IDWT |
| 96 | will be performed multiple times along these axes. |
| 97 | |
| 98 | Examples |
| 99 | -------- |
| 100 | >>> import numpy as np |
| 101 | >>> import pywt |
| 102 | >>> data = np.array([[1,2], [3,4]], dtype=np.float64) |
| 103 | >>> coeffs = pywt.dwt2(data, 'haar') |
| 104 | >>> pywt.idwt2(coeffs, 'haar') |
| 105 | array([[ 1., 2.], |
| 106 | [ 3., 4.]]) |
| 107 | |
| 108 | """ |
| 109 | # L -low-pass data, H - high-pass data |
| 110 | LL, (HL, LH, HH) = coeffs |
| 111 | axes = tuple(axes) |
| 112 | if len(axes) != 2: |
| 113 | raise ValueError("Expected 2 axes") |
| 114 | |
| 115 | coeffs = {'aa': LL, 'da': HL, 'ad': LH, 'dd': HH} |
| 116 | return idwtn(coeffs, wavelet, mode, axes) |
| 117 | |
| 118 | |
| 119 | def dwtn(data, wavelet, mode='symmetric', axes=None): |
no test coverage detected