@@ -33,7 +33,7 @@ results using wavelets.
3333 :meth: `pygsp.graphs.Graph.compute_fourier_basis `, but this would take some
3434 time, and can be avoided with a Chebychev polynomials approximation to
3535 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
3737 :cite: `hammond2011wavelets ` for details on how it is down.
3838
3939Simple filtering: heat diffusion
@@ -56,17 +56,16 @@ vertex 20. That signal is our heat source.
5656 :context: close-figs
5757
5858 >>> s = np.zeros(G.N)
59- >>> delta = 20
60- >>> s[delta ] = 1
59+ >>> DELTA = 20
60+ >>> s[DELTA ] = 1
6161
6262We can now simulate heat diffusion by filtering our signal `s ` with each of our
6363heat kernels.
6464
6565.. plot ::
6666 :context: close-figs
6767
68- >>> s = g.analysis(s, method = ' chebyshev' )
69- >>> s = utils.vec2mat(s, g.Nf)
68+ >>> s = g.filter(s, method = ' chebyshev' )
7069
7170And finally plot the filtered signal showing heat diffusion at different
7271scales.
@@ -77,7 +76,7 @@ scales.
7776 >>> fig = plt.figure(figsize = (10 , 3 ))
7877 >>> for i in range (g.Nf):
7978 ... 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)
8180 ... title = r ' Heat diffusion, $ \t au={}$ ' .format(taus[i])
8281 ... ax.set_title(title) # doctest:+SKIP
8382 ... ax.set_axis_off()
@@ -117,29 +116,19 @@ Then plot the frequency response of those filters.
117116 bank with :class: `pygsp.filters.WarpedTranslates ` or by using another
118117 filter bank like :class: `pygsp.filters.Itersine `.
119118
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.
122121
123122.. plot ::
124123 :context: close-figs
125124
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 )
131126 >>>
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
143132 ... ax.set_axis_off()
144133 >>> fig.tight_layout() # doctest:+SKIP
145134
@@ -160,16 +149,15 @@ which describes variation along the 3 coordinates.
160149 :context: close-figs
161150
162151 >>> s = G.coords
163- >>> s = g.analysis(s)
164- >>> s = utils.vec2mat(s, g.Nf)
152+ >>> s = g.filter(s)
165153
166154The 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 .
168156
169157.. plot ::
170158 :context: close-figs
171159
172- >>> s = np.linalg.norm(s, ord = 2 , axis = 2 )
160+ >>> s = np.linalg.norm(s, ord = 2 , axis = 1 )
173161
174162Let's finally plot the result to observe that we indeed have a measure of the
175163curvature at different scales.
@@ -180,7 +168,7 @@ curvature at different scales.
180168 >>> fig = plt.figure(figsize = (10 , 7 ))
181169 >>> for i in range (4 ):
182170 ... 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)
184172 ... title = ' Curvature estimation (scale {} )' .format(i+ 1 )
185173 ... ax.set_title(title) # doctest:+SKIP
186174 ... ax.set_axis_off()
0 commit comments