Exemple #1
0
 def test_meyer(self):
     f = filters.Meyer(self._G, Nf=4)
     self._test_methods(f, tight=True)
Exemple #2
0
"""
Instantiate and plot wavelet filter banks on graphs

Author: Shashwat Shukla
Date: 2nd June 2020
"""
# Import libraries
import numpy as np
import matplotlib.pyplot as plt
from pygsp import graphs, filters, plotting, utils

# Meyer wavelets on a ring
G = graphs.Ring(400)
G.estimate_lmax()
g = filters.Meyer(G, Nf=6)
fig, ax = plt.subplots(figsize=(10, 5))
g.plot(ax=ax)
_ = ax.set_title('Filter bank of Meyer wavelets')

DELTA = 255
s = g.localize(DELTA)
fig = plt.figure(figsize=(10, 2.5))
for i in range(4):
    ax = fig.add_subplot(1, 4, i + 1, projection='3d')
    G.plot_signal(s[:, i], ax=ax)
    _ = ax.set_title('Wavelet {}'.format(i + 1))
    ax.set_axis_off()
fig.tight_layout()
plt.show()

# Mexican hat wavelets on a torus
import matplotlib.pyplot as plt
import numpy as np
G = graphs.Comet()
G.compute_fourier_basis()  # Fourier to plot the eigenvalues.
# lmax = G.estimate_lmax()
# print('{:.2f}'.format(G.lmax))
DELTAS = [2, 20]
s = np.zeros(G.N)
s[DELTAS] = 1

# Fig.1
fig = plt.figure(figsize=(25, 15))
ax = fig.add_subplot(3, 3, 1)
G.plot(s, ax=ax)

g = filters.Meyer(G)
# g = filters.Meyer(G,scales=[5,2,1,0.6,0.4])
scales = [0] + g.scales.tolist()
print(scales)
s = g.filter(s, method='exact')
# g2 = filters.Heat(G, scale=5)
# s2 = g2.filter(s)

ax = fig.add_subplot(3, 3, 2)
title = 'Meyer Scaling(scale={})'.format(scales[0])
G.plot(s[:, 0], ax=ax, title=title)
# G.plot(s[:, 0], ax=ax, title='Meyer Scaling', highlight=DELTAS)
ax.set_axis_off()

for i in range(1, 6):
    ax = fig.add_subplot(3, 3, i + 2)
Exemple #4
0
 def test_meyer(G):
     g = filters.Meyer(G, Nf=4)