| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
import numpy as np |
| 5 |
import matplotlib.pyplot as plt |
| 6 |
|
| 7 |
from pywt import WaveletPacketND |
| 8 |
import pywt.data |
| 9 |
|
| 10 |
|
| 11 |
arr = pywt.data.aero() |
| 12 |
|
| 13 |
maxlevel = 2 |
| 14 |
wp2 = WaveletPacketND(arr, 'db2', 'symmetric', maxlevel=maxlevel) |
| 15 |
|
| 16 |
|
| 17 |
plt.imshow(arr, interpolation="nearest", cmap=plt.cm.gray) |
| 18 |
|
| 19 |
fig = plt.figure() |
| 20 |
i = 1 |
| 21 |
nsubplots = len(wp2.get_level(maxlevel, 'natural')) |
| 22 |
nrows = int(np.floor(np.sqrt(nsubplots))) |
| 23 |
ncols = int(np.ceil(nsubplots/nrows)) |
| 24 |
for node in wp2.get_level(maxlevel, 'natural'): |
| 25 |
ax = fig.add_subplot(nrows, ncols, i) |
| 26 |
ax.set_title("%s" % (node.path_tuple, )) |
| 27 |
ax.imshow(np.sqrt(np.abs(node.data)), origin='upper', |
| 28 |
interpolation="nearest", cmap=plt.cm.gray) |
| 29 |
ax.set_axis_off() |
| 30 |
i += 1 |
| 31 |
|
| 32 |
plt.show() |