-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdemo_extension.m
116 lines (90 loc) · 4.49 KB
/
demo_extension.m
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
% Demo of extending our proposed spherical conformal mapping algorithm [1]
% for further reducing the area distortion via a Mobius transformation [2]
% while preserving the conformality
%
% If you use this code in your own work, please cite the following papers:
% (For spherical_conformal_map.m)
% [1] P. T. Choi, K. C. Lam, and L. M. Lui,
% "FLASH: Fast Landmark Aligned Spherical Harmonic Parameterization for Genus-0 Closed Brain Surfaces."
% SIAM Journal on Imaging Sciences, vol. 8, no. 1, pp. 67-94, 2015.
%
% (For mobius_area_correction_spherical.m)
% [2] G. P. T. Choi, Y. Leung-Liu, X. Gu, and L. M. Lui,
% "Parallelizable global conformal parameterization of simply-connected surfaces via partial welding."
% SIAM Journal on Imaging Sciences, 2020.
% Copyright (c) 2013-2020, Gary Pui-Tung Choi
% https://scholar.harvard.edu/choi
addpath('mfile')
addpath('extension') % contain the codes for the area correction
%% Example 1: David
load('david.mat')
plot_mesh(v,f); view([-130 0])
%% our linear method for spherical conformal map ([1])
map = spherical_conformal_map(v,f);
plot_mesh(map,f); title('Spherical conformal map')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));
%% Extension: our linear method for spherical conformal map together with a Mobius area correction step ([1] + [2])
map = spherical_conformal_map(v,f);
map = mobius_area_correction_spherical(v,f,map);
plot_mesh(map,f); title('Spherical conformal map with Mobius area correction')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));
%% Example 2: Lion
load('lion.mat')
plot_mesh(v,f,mean_curv);
%% our linear method for spherical conformal map ([1])
map = spherical_conformal_map(v,f);
plot_mesh(map,f,mean_curv); view([-70 0]); title('Spherical conformal map')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));
%% Extension: our linear method for spherical conformal map together with a Mobius area correction step ([1] + [2])
map = spherical_conformal_map(v,f);
map = mobius_area_correction_spherical(v,f,map);
plot_mesh(map,f,mean_curv); view([-70 0]); title('Spherical conformal map with Mobius area correction')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));
%% Example 3: Brain
load('brain.mat')
plot_mesh(v,f,mean_curv); view([90 0]);
%% our linear method for spherical conformal map ([1])
map = spherical_conformal_map(v,f);
plot_mesh(map,f,mean_curv); view([-30 0]); title('Spherical conformal map')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));
%% Extension: our linear method for spherical conformal map together with a Mobius area correction step ([1]+[2])
map = spherical_conformal_map(v,f);
map = mobius_area_correction_spherical(v,f,map);
plot_mesh(map,f,mean_curv); view([-30 0]); title('Spherical conformal map with Mobius area correction')
% evaluate the angle and area distortion
d = angle_distortion(v,f,map);
a = area_distortion(v,f,map);
fprintf('Mean(angle distortion) = %.4f\n',mean(abs(d)));
fprintf('SD(angle distortion) = %.4f\n',std(abs(d)));
fprintf('Mean(area distortion) = %.4f\n',mean(abs(a)));
fprintf('SD(area distortion) = %.4f\n',std(abs(a)));