-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #393 from grlee77/wpacket_nd_and_axis
Wavelet packets: extend to nD and support subsets of the axes
- Loading branch information
Showing
7 changed files
with
794 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env python | ||
# Note: This demo is a repeat of wp_2d, but using WaveletPacketND instead | ||
|
||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
from pywt import WaveletPacketND | ||
import pywt.data | ||
|
||
|
||
arr = pywt.data.aero() | ||
|
||
maxlevel = 2 | ||
wp2 = WaveletPacketND(arr, 'db2', 'symmetric', maxlevel=maxlevel) | ||
|
||
# Show original figure | ||
plt.imshow(arr, interpolation="nearest", cmap=plt.cm.gray) | ||
|
||
fig = plt.figure() | ||
i = 1 | ||
nsubplots = len(wp2.get_level(maxlevel, 'natural')) | ||
nrows = int(np.floor(np.sqrt(nsubplots))) | ||
ncols = int(np.ceil(nsubplots/nrows)) | ||
for node in wp2.get_level(maxlevel, 'natural'): | ||
ax = fig.add_subplot(nrows, ncols, i) | ||
ax.set_title("%s" % (node.path_tuple, )) | ||
ax.imshow(np.sqrt(np.abs(node.data)), origin='upper', | ||
interpolation="nearest", cmap=plt.cm.gray) | ||
ax.set_axis_off() | ||
i += 1 | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.