Skip to content

Commit

Permalink
Adding Fast GSSS as an optional dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
bgirault-usc committed Mar 22, 2019
1 parent 38471b9 commit b8dace9
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 15 deletions.
10 changes: 10 additions & 0 deletions 3rdParty/grasp_dependencies_list.m
Expand Up @@ -145,4 +145,14 @@
list(cur_dep).root_dir = 'GraphStructures-master/';
list(cur_dep).path_list = {'ToyGraphGSPExample/'};
list(cur_dep).optional = 1;

cur_dep = cur_dep + 1;

list(cur_dep).url = 'https://github.com/ychtanaka/FastGSSS/archive/master.zip';
list(cur_dep).name = 'fast_gsss/';
list(cur_dep).root_dir = 'FastGSSS-master/';
list(cur_dep).path_list = {'.'};
list(cur_dep).optional = 1;
list(cur_dep).ref_bib = 'To appear in IEEE TSP';
list(cur_dep).dependencies = {'sgwt'};
end
39 changes: 29 additions & 10 deletions Operators/grasp_translation.m
@@ -1,11 +1,16 @@
%Computes the graph translation [Girault et al. 2015, IEEE SPL].
%Computes the graph translation operator [Girault et al. 2015, IEEE SPL].
%
% T = GRASP_TRANSLATION(graph) uses the graph structure to build its
% graph translation.
% filter = GRASP_TRANSLATION(graph) uses the graph structure to build its
% graph translation.
%
% T = GRASP_TRANSLATION(..., freqs) use the given frequencies instead of
% the ones from [Girault et al. 2015, IEEE SPL]. The resulting operator
% verifies T\chi_l=exp(-i * 2 * pi * freqs(l)) \chi_l.
% filter = GRASP_TRANSLATION(..., freqs) use the given frequencies
% instead of the ones from [Girault et al. 2015, IEEE SPL]. The
% resulting operator verifies
% T\chi_l=exp(-i * 2 * pi * freqs(l)) \chi_l.
%
% [..., T] = GRASP_TRANSLATION(...) also returns the matrix of the graph
% translation operator. This may be faster than using
% GRASP_APPLY_FILTER.
%
% Authors:
% - Benjamin Girault <benjamin.girault@ens-lyon.fr>
Expand Down Expand Up @@ -48,17 +53,27 @@
% The fact that you are presently reading this means that you have had
% knowledge of the CeCILL license and that you accept its terms.

function T = grasp_translation(graph, freqs)
function [filter, T] = grasp_translation(graph, freqs)
%% Check
if ~isfield(graph, 'fourier_version') || strcmp(graph.fourier_version, 'n.a.')
error('GraSP:Translation:MissingGFT', 'Missing GFT! Please run grasp_eigendecomposition first.');
end

%% Use the provided freqs if given
if nargin == 2
T = grasp_fourier_inverse(graph, diag(exp(-1i * 2 * pi * freqs)));
filter.type = 'convolution';
filter.data = exp(-1i * 2 * pi * freqs);
if nargout == 2
% T = grasp_fourier_inverse(graph, diag(exp(-1i * 2 * pi * freqs)));
T = grasp_apply_filter(graph, filter);
end
return;
end

%% Intialization
if ~strcmp(graph.fourier_version, 'standard laplacian') && ~strcmp(graph.fourier_version, 'normalized laplacian')
if ~(strcmp(graph.fourier_version, 'graph shift') && ~grasp_is_directed(graph))
error('Error: The Fourier transform should be the result of the decomposition of a Laplacian matrix, or a symmetric graph shift!');
error('GraSP:Translation:InvalidGFT', 'Error: The Fourier transform should be the result of the decomposition of a Laplacian matrix, or a symmetric graph shift!');
end
end

Expand All @@ -76,5 +91,9 @@
end

%% Translation operator
T = expm(-1i * pi * sqrtm(full(graph.L) / rho));
filter.type = 'kernel';
filter.data = @(x) exp(-1i * pi * sqrtm(x / rho));
if nargout == 2
T = expm(-1i * pi * sqrtm(full(graph.Z) / rho));
end
end
49 changes: 45 additions & 4 deletions Plotting/grasp_generate_gif.m
Expand Up @@ -47,29 +47,70 @@
% The fact that you are presently reading this means that you have had
% knowledge of the CeCILL license and that you accept its terms.

function grasp_generate_gif(fh, filename, graph, signals, titles, title_font_size, show_graph_options)
function grasp_generate_gif(fh, filename, graph, signals, titles, title_font_size, show_graph_options, varargin)
%% Parameters
default_param = struct(...
'signals_delays', 0.1,...
'overlay_function', [],...
'overlay_update', []);
if nargin == 7
options = struct;
elseif nargin > 8
options = cell2struct(varargin(2:2:end), varargin(1:2:end), 2);
else
options = varargin{1};
end
options = grasp_merge_structs(default_param, options);

%% Initializations
ah = get(fh, 'CurrentAxes');
% disp('<show_graph>');
nh = grasp_show_graph(ah, graph, show_graph_options);
% disp('</show_graph>');
overlay_h = [];
if numel(options.overlay_function) > 0
hold(ah, 'on');
overlay_h = options.overlay_function(ah);
hold(ah, 'off');
end
colorbar;
% disp('<set>');
set(fh, 'color', 'w');
% disp('</set>');
if numel(options.signals_delays) == 1
options.signals_delays = options.signals_delays * ones(size(signals, 2), 1);
end

%% Code
% disp('<set>');
set(nh, 'CData', signals(:, 1));
% disp('</set>');
if numel(options.overlay_update) > 0
options.overlay_update(overlay_h, 1);
end
drawnow;
f = getframe(fh);
if ~grasp_is_octave()
[im, map] = rgb2ind(f.cdata, 256, 'nodither');
else
[im, map] = rgb2ind(f.cdata);
end
imwrite(im, map, filename, 'DelayTime', 0.1, 'LoopCount', inf);
for k = 1:size(signals, 2)
imwrite(im, map, filename, 'DelayTime', options.signals_delays(1), 'LoopCount', inf);
for k = 2:size(signals, 2)
title(ah, titles{k}, 'interpreter', 'latex', 'fontsize', title_font_size);
% disp('<set>');
set(nh, 'CData', signals(:, k));
% disp('</set>');
if numel(options.overlay_update) > 0
options.overlay_update(overlay_h, k);
end
drawnow;
f = getframe(fh);
if ~grasp_is_octave()
[im, map] = rgb2ind(f.cdata, 256, 'nodither');
else
[im, map] = rgb2ind(f.cdata);
end
imwrite(im, map, filename, 'DelayTime', 0.1, 'WriteMode', 'append');
imwrite(im, map, filename, 'DelayTime', options.signals_delays(k), 'WriteMode', 'append');
end
end
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Expand Up @@ -22,6 +22,8 @@

### New Third Party Toolboxes

* [FastGSSS](https://github.com/ychtanaka/FastGSSS)

### New Functions

* `grasp_clean_pdf_export`: Function to create nice PDFs, not cropped ones...
Expand Down
2 changes: 1 addition & 1 deletion doc/tuto.mwk
Expand Up @@ -51,6 +51,6 @@ Now that the GFT is defined, we can compute a more complex signal using [[grasp_

This signal is a low pass signal. We can then convolve the two signals using:

conv_sig = grasp_convolution(heat, delta_1);
conv_sig = grasp_convolution(g, heat, delta_1);

You can find more operators in the [[Operators]] folder.

0 comments on commit b8dace9

Please sign in to comment.