diff --git a/demo/dwt2_dwtn_image.py b/demo/dwt2_dwtn_image.py index a02fc6766..55013a72b 100644 --- a/demo/dwt2_dwtn_image.py +++ b/demo/dwt2_dwtn_image.py @@ -13,9 +13,9 @@ titles = ['Approximation', ' Horizontal detail', 'Vertical detail', 'Diagonal detail'] coeffs2 = pywt.dwt2(original, 'bior1.3') -LL, (LH, HL, HH) = coeffs2 +LL, (HL, LH, HH) = coeffs2 fig = plt.figure() -for i, a in enumerate([LL, LH, HL, HH]): +for i, a in enumerate([LL, HL, LH, HH]): ax = fig.add_subplot(2, 2, i + 1) ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) ax.set_title(titles[i], fontsize=12) @@ -37,7 +37,7 @@ coeffsn = pywt.dwtn(original, 'bior1.3') fig = plt.figure() -for i, key in enumerate(['aa', 'ad', 'da', 'dd']): +for i, key in enumerate(['aa', 'da', 'ad', 'dd']): ax = fig.add_subplot(2, 2, i + 1) ax.imshow(coeffsn[key], interpolation="nearest", cmap=plt.cm.gray) ax.set_title(titles[i], fontsize=12) diff --git a/doc/source/pyplots/camera_approx_detail.py b/doc/source/pyplots/camera_approx_detail.py index 513b290c8..2e41fe8d7 100644 --- a/doc/source/pyplots/camera_approx_detail.py +++ b/doc/source/pyplots/camera_approx_detail.py @@ -11,9 +11,9 @@ titles = ['Approximation', ' Horizontal detail', 'Vertical detail', 'Diagonal detail'] coeffs2 = pywt.dwt2(original, 'bior1.3') -LL, (LH, HL, HH) = coeffs2 +LL, (HL, LH, HH) = coeffs2 fig = plt.figure(figsize=(12, 3)) -for i, a in enumerate([LL, LH, HL, HH]): +for i, a in enumerate([LL, HL, LH, HH]): ax = fig.add_subplot(1, 4, i + 1) ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) ax.set_title(titles[i], fontsize=10) diff --git a/doc/source/ref/2d-dwt-and-idwt.rst b/doc/source/ref/2d-dwt-and-idwt.rst index a1503344e..8b68ef5b6 100644 --- a/doc/source/ref/2d-dwt-and-idwt.rst +++ b/doc/source/ref/2d-dwt-and-idwt.rst @@ -12,23 +12,23 @@ Single level ``dwt2`` .. autofunction:: dwt2 -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: +The following diagram shows the coefficients packed into a single array +with the default axes. This matches :func:`coeffs_to_array` applied to the +output of :func:`wavedec2` with ``level=1``: :: ------------------- | | | - | cA(LL) | cH(LH) | + | cA(LL) | cV(LH) | | | | (cA, (cH, cV, cD)) <---> ------------------- | | | - | cV(HL) | cD(HH) | + | cH(HL) | cD(HH) | | | | ------------------- -PyWavelets does not follow this pattern because of pure practical reasons of simple -access to particular type of the output coefficients. +:func:`dwt2` returns separate arrays for direct access to each subband. Single level ``idwt2`` diff --git a/doc/source/ref/wavelet-packets.rst b/doc/source/ref/wavelet-packets.rst index fd4c96b5a..cb07264c0 100644 --- a/doc/source/ref/wavelet-packets.rst +++ b/doc/source/ref/wavelet-packets.rst @@ -313,8 +313,8 @@ WaveletPacket2D and Node2D For :class:`WaveletPacket2D` case it is just as in :func:`dwt2`: - ``a`` - approximation coefficients (`LL`) - - ``h`` - horizontal detail coefficients (`LH`) - - ``v`` - vertical detail coefficients (`HL`) + - ``h`` - horizontal detail coefficients (`HL`) + - ``v`` - vertical detail coefficients (`LH`) - ``d`` - diagonal detail coefficients (`HH`) .. method:: decompose() diff --git a/doc/source/regression/wp2d.md b/doc/source/regression/wp2d.md index 178d1e689..fb916a24e 100644 --- a/doc/source/regression/wp2d.md +++ b/doc/source/regression/wp2d.md @@ -80,8 +80,8 @@ children), we have four basic path names based on the dwt 2D output convention to address the WP2D structure: - `a` - LL, low-low coefficients -- `h` - LH, low-high coefficients -- `v` - HL, high-low coefficients +- `h` - HL, high-low coefficients +- `v` - LH, low-high coefficients - `d` - HH, high-high coefficients In other words, subnode naming corresponds to the `dwt2` function output @@ -90,11 +90,11 @@ naming convention (as wavelet packet transform is based on the dwt2 transform): ``` ------------------- | | | - | cA(LL) | cH(LH) | + | cA(LL) | cV(LH) | | | | (cA, (cH, cV, cD)) <---> ------------------- | | | - | cV(HL) | cD(HH) | + | cH(HL) | cD(HH) | | | | ------------------- diff --git a/pywt/_multidim.py b/pywt/_multidim.py index 361c2cf25..ec95d0840 100644 --- a/pywt/_multidim.py +++ b/pywt/_multidim.py @@ -25,7 +25,8 @@ def dwt2(data, wavelet, mode='symmetric', axes=(-2, -1)): Parameters ---------- data : array_like - 2D array with input data + Input array. With more than two dimensions, the transform is + applied only along the selected axes. 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``. @@ -34,15 +35,19 @@ def dwt2(data, wavelet, mode='symmetric', axes=(-2, -1)): also be a tuple of modes specifying the mode to use on each axis in ``axes``. axes : 2-tuple of ints, optional - Axes over which to compute the DWT. Repeated elements mean the DWT will - be performed multiple times along these axes. + Axes over which to compute the DWT. The default is the last two axes. + Repeated elements mean the DWT is performed multiple times along the + same axis. Returns ------- (cA, (cH, cV, cD)) : tuple Approximation, horizontal detail, vertical detail and diagonal - detail coefficients respectively. Horizontal refers to array axis 0 - (or ``axes[0]`` for user-specified ``axes``). + detail coefficients, respectively. The horizontal detail (``cH``) + uses high-pass filtering along ``axes[0]`` and low-pass filtering along + ``axes[1]``. The vertical detail (``cV``) uses low-pass filtering along + ``axes[0]`` and high-pass filtering along ``axes[1]``. The diagonal detail + (``cD``) uses high-pass filtering along both. Examples --------