Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions demo/dwt2_dwtn_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions doc/source/pyplots/camera_approx_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions doc/source/ref/2d-dwt-and-idwt.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
4 changes: 2 additions & 2 deletions doc/source/ref/wavelet-packets.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions doc/source/regression/wp2d.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) |
| | |
-------------------

Expand Down
15 changes: 10 additions & 5 deletions pywt/_multidim.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand All @@ -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
--------
Expand Down