@@ -33,7 +33,7 @@ results using wavelets.
33
33
:meth: `pygsp.graphs.Graph.compute_fourier_basis `, but this would take some
34
34
time, and can be avoided with a Chebychev polynomials approximation to
35
35
graph filtering. See the documentation of the
36
- :meth: `pygsp.filters.Filter.analysis ` filtering function and
36
+ :meth: `pygsp.filters.Filter.filter ` filtering function and
37
37
:cite: `hammond2011wavelets ` for details on how it is down.
38
38
39
39
Simple filtering: heat diffusion
@@ -56,17 +56,16 @@ vertex 20. That signal is our heat source.
56
56
:context: close-figs
57
57
58
58
>>> s = np.zeros(G.N)
59
- >>> delta = 20
60
- >>> s[delta ] = 1
59
+ >>> DELTA = 20
60
+ >>> s[DELTA ] = 1
61
61
62
62
We can now simulate heat diffusion by filtering our signal `s ` with each of our
63
63
heat kernels.
64
64
65
65
.. plot ::
66
66
:context: close-figs
67
67
68
- >>> s = g.analysis(s, method = ' chebyshev' )
69
- >>> s = utils.vec2mat(s, g.Nf)
68
+ >>> s = g.filter(s, method = ' chebyshev' )
70
69
71
70
And finally plot the filtered signal showing heat diffusion at different
72
71
scales.
@@ -77,7 +76,7 @@ scales.
77
76
>>> fig = plt.figure(figsize = (10 , 3 ))
78
77
>>> for i in range (g.Nf):
79
78
... ax = fig.add_subplot(1 , g.Nf, i+ 1 , projection = ' 3d' )
80
- ... G.plot_signal(s[:, i], vertex_size = 20 , colorbar = False , ax = ax)
79
+ ... G.plot_signal(s[:, 0 , i] , colorbar = False , ax = ax)
81
80
... title = r ' Heat diffusion, $ \t au={}$ ' .format(taus[i])
82
81
... ax.set_title(title) # doctest:+SKIP
83
82
... ax.set_axis_off()
@@ -117,29 +116,19 @@ Then plot the frequency response of those filters.
117
116
bank with :class: `pygsp.filters.WarpedTranslates ` or by using another
118
117
filter bank like :class: `pygsp.filters.Itersine `.
119
118
120
- We can visualize the filtering by one atom as we did with the heat kernel, by
121
- filtering a Kronecker delta placed at one specific vertex.
119
+ We can visualize the atoms as we did with the heat kernel, by filtering
120
+ a Kronecker delta placed at one specific vertex.
122
121
123
122
.. plot ::
124
123
:context: close-figs
125
124
126
- >>> s = np.zeros((G.N * g.Nf, g.Nf))
127
- >>> s[delta] = 1
128
- >>> for i in range (g.Nf):
129
- ... s[delta + i * G.N, i] = 1
130
- >>> s = g.synthesis(s)
125
+ >>> s = g.localize(DELTA )
131
126
>>>
132
- >>> fig = plt.figure(figsize = (10 , 7 ))
133
- >>> for i in range (4 ):
134
- ...
135
- ... # Clip the signal.
136
- ... mu = np.mean(s[:, i])
137
- ... sigma = np.std(s[:, i])
138
- ... limits = [mu- 4 * sigma, mu+ 4 * sigma]
139
- ...
140
- ... ax = fig.add_subplot(2 , 2 , i+ 1 , projection = ' 3d' )
141
- ... G.plot_signal(s[:, i], vertex_size = 20 , limits = limits, ax = ax)
142
- ... ax.set_title(' Wavelet {} ' .format(i+ 1 )) # doctest:+SKIP
127
+ >>> fig = plt.figure(figsize = (10 , 2.5 ))
128
+ >>> for i in range (3 ):
129
+ ... ax = fig.add_subplot(1 , 3 , i+ 1 , projection = ' 3d' )
130
+ ... G.plot_signal(s[:, 0 , i], ax = ax)
131
+ ... ax.set_title(' Wavelet {} ' .format(i+ 1 )) # doctest:+SKIP
143
132
... ax.set_axis_off()
144
133
>>> fig.tight_layout() # doctest:+SKIP
145
134
@@ -160,16 +149,15 @@ which describes variation along the 3 coordinates.
160
149
:context: close-figs
161
150
162
151
>>> s = G.coords
163
- >>> s = g.analysis(s)
164
- >>> s = utils.vec2mat(s, g.Nf)
152
+ >>> s = g.filter(s)
165
153
166
154
The curvature is then estimated by taking the :math: `\ell _1 ` or :math: `\ell _2 `
167
- norm of the filtered signal .
155
+ norm across the 3D position .
168
156
169
157
.. plot ::
170
158
:context: close-figs
171
159
172
- >>> s = np.linalg.norm(s, ord = 2 , axis = 2 )
160
+ >>> s = np.linalg.norm(s, ord = 2 , axis = 1 )
173
161
174
162
Let's finally plot the result to observe that we indeed have a measure of the
175
163
curvature at different scales.
@@ -180,7 +168,7 @@ curvature at different scales.
180
168
>>> fig = plt.figure(figsize = (10 , 7 ))
181
169
>>> for i in range (4 ):
182
170
... ax = fig.add_subplot(2 , 2 , i+ 1 , projection = ' 3d' )
183
- ... G.plot_signal(s[:, i], vertex_size = 20 , ax = ax)
171
+ ... G.plot_signal(s[:, i], ax = ax)
184
172
... title = ' Curvature estimation (scale {} )' .format(i+ 1 )
185
173
... ax.set_title(title) # doctest:+SKIP
186
174
... ax.set_axis_off()
0 commit comments