Debian Codegraph @

demo/swt2.py

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