1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import pywt
import pywt.data
arr = pywt.data.aero()
plt.imshow(arr, interpolation="nearest", cmap=plt.cm.gray)
level = 0
titles = ['Approximation', ' Horizontal detail',
'Vertical detail', 'Diagonal detail']
for LL, (LH, HL, HH) in pywt.swt2(arr, 'bior1.3', level=3, start_level=0):
fig = plt.figure()
for i, a in enumerate([LL, LH, HL, HH]):
ax = fig.add_subplot(2, 2, i + 1)
ax.imshow(a, origin='upper', interpolation="nearest", cmap=plt.cm.gray)
ax.set_title(titles[i], fontsize=12)
fig.suptitle("SWT2 coefficients, level %s" % level, fontsize=14)
level += 1
plt.show()
|