| 1 |
import numpy as np |
| 2 |
import matplotlib.pyplot as plt |
| 3 |
|
| 4 |
import pywt |
| 5 |
import pywt.data |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
original = pywt.data.camera() |
| 10 |
|
| 11 |
|
| 12 |
titles = ['Approximation', ' Horizontal detail', |
| 13 |
'Vertical detail', 'Diagonal detail'] |
| 14 |
coeffs2 = pywt.dwt2(original, 'bior1.3') |
| 15 |
LL, (LH, HL, HH) = coeffs2 |
| 16 |
fig = plt.figure(figsize=(12, 3)) |
| 17 |
for i, a in enumerate([LL, LH, HL, HH]): |
| 18 |
ax = fig.add_subplot(1, 4, i + 1) |
| 19 |
ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) |
| 20 |
ax.set_title(titles[i], fontsize=10) |
| 21 |
ax.set_xticks([]) |
| 22 |
ax.set_yticks([]) |
| 23 |
|
| 24 |
fig.tight_layout() |
| 25 |
plt.show() |