Multilevel 2D Discrete Wavelet Transform. Parameters ---------- data : ndarray 2D input data wavelet : Wavelet object or name string, or 2-tuple of wavelets Wavelet to use. This can also be a tuple containing a wavelet to apply along each axis in ``axes
(data, wavelet, mode='symmetric', level=None, axes=(-2, -1))
| 177 | |
| 178 | |
| 179 | def wavedec2(data, wavelet, mode='symmetric', level=None, axes=(-2, -1)): |
| 180 | """ |
| 181 | Multilevel 2D Discrete Wavelet Transform. |
| 182 | |
| 183 | Parameters |
| 184 | ---------- |
| 185 | data : ndarray |
| 186 | 2D input data |
| 187 | wavelet : Wavelet object or name string, or 2-tuple of wavelets |
| 188 | Wavelet to use. This can also be a tuple containing a wavelet to |
| 189 | apply along each axis in ``axes``. |
| 190 | mode : str or 2-tuple of str, optional |
| 191 | Signal extension mode, see :ref:`Modes <ref-modes>`. This can |
| 192 | also be a tuple containing a mode to apply along each axis in ``axes``. |
| 193 | level : int, optional |
| 194 | Decomposition level (must be >= 0). If level is None (default) then it |
| 195 | will be calculated using the ``dwt_max_level`` function. |
| 196 | axes : 2-tuple of ints, optional |
| 197 | Axes over which to compute the DWT. Repeated elements are not allowed. |
| 198 | |
| 199 | Returns |
| 200 | ------- |
| 201 | [cAn, (cHn, cVn, cDn), ... (cH1, cV1, cD1)] : list |
| 202 | Coefficients list. For user-specified ``axes``, ``cH*`` |
| 203 | corresponds to ``axes[0]`` while ``cV*`` corresponds to ``axes[1]``. |
| 204 | The first element returned is the approximation coefficients for the |
| 205 | nth level of decomposition. Remaining elements are tuples of detail |
| 206 | coefficients in descending order of decomposition level. |
| 207 | (i.e. ``cH1`` are the horizontal detail coefficients at the first |
| 208 | level) |
| 209 | |
| 210 | Examples |
| 211 | -------- |
| 212 | >>> import pywt |
| 213 | >>> import numpy as np |
| 214 | >>> coeffs = pywt.wavedec2(np.ones((4,4)), 'db1') |
| 215 | >>> # Levels: |
| 216 | >>> len(coeffs)-1 |
| 217 | 2 |
| 218 | >>> pywt.waverec2(coeffs, 'db1') |
| 219 | array([[ 1., 1., 1., 1.], |
| 220 | [ 1., 1., 1., 1.], |
| 221 | [ 1., 1., 1., 1.], |
| 222 | [ 1., 1., 1., 1.]]) |
| 223 | """ |
| 224 | data = np.asarray(data) |
| 225 | if data.ndim < 2: |
| 226 | raise ValueError("Expected input data to have at least 2 dimensions.") |
| 227 | |
| 228 | axes = tuple(axes) |
| 229 | if len(axes) != 2: |
| 230 | raise ValueError("Expected 2 axes") |
| 231 | if len(axes) != len(set(axes)): |
| 232 | raise ValueError("The axes passed to wavedec2 must be unique.") |
| 233 | try: |
| 234 | axes_sizes = [data.shape[ax] for ax in axes] |
| 235 | except IndexError: |
| 236 | raise AxisError("Axis greater than data dimensions") |
nothing calls this directly
no test coverage detected