-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.m
More file actions
63 lines (41 loc) · 1.22 KB
/
example.m
File metadata and controls
63 lines (41 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
% SPECTRAL TV DECOMPOSITION
clear ; clc ; close all
addpath(genpath('./'))
%% load data
path="./DATA/garg.off";
M=load_off(path);
% center and scale mesh
M.VERT = M.VERT - mean(M.VERT);
M.VERT = M.VERT./max(std(M.VERT));
%compute the normal vector field of M
u0 = compute_normals(M);
%% set the hyperparameters for the decomposition
%alpha corresponds to the maximum diffusion time
alpha=100;
%Ncomp is the number of spectral compnonuniformnts to be computed
Ncomp=40;
%nonuniform: binary flag indicating whether alpha is scaled uniformly
nonuniform=1;
%regFact: is the scale factor for alpha
if nonuniform
%alpha is updated as \alpha_{t+1}=reg_fact*\alpha_t
regFact=0.8;
else
%alpha is updated as \alpha_{t+1}=\alpha_t -reg_fact*\alpha
regFact=1/100;
end
tt=timescale_iss(alpha,regFact,Ncomp,nonuniform);
[M.sub,M.phi]=decomposeNormals(M,u0,alpha,Ncomp,regFact,nonuniform,1);
%% compute and plot the TV spectrum
M.A=diag(calc_tri_areas(M));
S=(sum(abs(diag(M.A).*normv(M.phi))));
S=squeeze(S)';
figure
j=plot(S);
xlabel("$t$","Interpreter","latex")
ylabel("$S(t)$","Interpreter","latex")
title("TV spectrum")
%% starts the interactive GUI according to the computed decomposition
M.f=u0;
S(1)=S(2);
start_gui(S,M)