MCPcopy Create free account
hub / github.com/PyWavelets/pywt / dwt2

Function dwt2

pywt/_multidim.py:22–72  ·  view source on GitHub ↗

2D Discrete Wavelet Transform. Parameters ---------- data : array_like 2D array with 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 ``a

(data, wavelet, mode='symmetric', axes=(-2, -1))

Source from the content-addressed store, hash-verified

20
21
22def dwt2(data, wavelet, mode='symmetric', axes=(-2, -1)):
23 """
24 2D Discrete Wavelet Transform.
25
26 Parameters
27 ----------
28 data : array_like
29 2D array with input data
30 wavelet : Wavelet object or name string, or 2-tuple of wavelets
31 Wavelet to use. This can also be a tuple containing a wavelet to
32 apply along each axis in ``axes``.
33 mode : str or 2-tuple of strings, optional
34 Signal extension mode, see :ref:`Modes <ref-modes>`. This can
35 also be a tuple of modes specifying the mode to use on each axis in
36 ``axes``.
37 axes : 2-tuple of ints, optional
38 Axes over which to compute the DWT. Repeated elements mean the DWT will
39 be performed multiple times along these axes.
40
41 Returns
42 -------
43 (cA, (cH, cV, cD)) : tuple
44 Approximation, horizontal detail, vertical detail and diagonal
45 detail coefficients respectively. Horizontal refers to array axis 0
46 (or ``axes[0]`` for user-specified ``axes``).
47
48 Examples
49 --------
50 >>> import numpy as np
51 >>> import pywt
52 >>> data = np.ones((4,4), dtype=np.float64)
53 >>> coeffs = pywt.dwt2(data, 'haar')
54 >>> cA, (cH, cV, cD) = coeffs
55 >>> cA
56 array([[ 2., 2.],
57 [ 2., 2.]])
58 >>> cV
59 array([[ 0., 0.],
60 [ 0., 0.]])
61
62 """
63 axes = tuple(axes)
64 data = np.asarray(data)
65 if len(axes) != 2:
66 raise ValueError("Expected 2 axes")
67 if data.ndim < len(np.unique(axes)):
68 raise ValueError("Input array has fewer dimensions than the specified "
69 "axes")
70
71 coefs = dwtn(data, wavelet, mode, axes)
72 return coefs['aa'], (coefs['da'], coefs['ad'], coefs['dd'])
73
74
75def idwt2(coeffs, wavelet, mode='symmetric', axes=(-2, -1)):

Callers 2

_decomposeMethod · 0.85
wavedec2Function · 0.85

Calls 1

dwtnFunction · 0.85

Tested by

no test coverage detected