|
9 | 9 | # Authors: Guillaume Auzias <[email protected]> |
10 | 10 | # Julien Barrès <[email protected]> |
11 | 11 |
|
12 | | -# License: BSD (3-clause) |
| 12 | +# License: MIT |
13 | 13 | # sphinx_gallery_thumbnail_number = 2 |
14 | 14 |
|
15 | | - |
16 | 15 | ############################################################################### |
| 16 | +# NOTE: there is no visualization tool in slam, but we provide at the |
| 17 | +# end of this script exemplare code to do the visualization with |
| 18 | +# an external solution |
| 19 | +############################################################################### |
| 20 | + |
17 | 21 | # importation of slam modules |
18 | 22 | import slam.utils as ut |
19 | 23 | import numpy as np |
20 | 24 | import slam.generate_parametric_surfaces as sgps |
21 | 25 | import slam.io as sio |
22 | | -import slam.plot as splt |
23 | 26 | import slam.curvature as scurv |
24 | 27 |
|
25 | 28 | ############################################################################### |
|
29 | 32 |
|
30 | 33 | ############################################################################### |
31 | 34 | # Comptue estimations of principal curvatures |
32 | | -PrincipalCurvatures, PrincipalDir1, PrincipalDir2 = scurv.curvatures_and_derivatives( |
33 | | - mesh |
34 | | -) |
| 35 | +PrincipalCurvatures, PrincipalDir1, PrincipalDir2 \ |
| 36 | + = scurv.curvatures_and_derivatives(mesh) |
35 | 37 |
|
36 | 38 | ############################################################################### |
37 | 39 | # Comptue Gauss curvature from principal curvatures |
|
41 | 43 | # Comptue mean curvature from principal curvatures |
42 | 44 | mean_curv = 0.5 * (PrincipalCurvatures[0, :] + PrincipalCurvatures[1, :]) |
43 | 45 |
|
44 | | -############################################################################### |
45 | | -# Plot mean curvature |
46 | | -visb_sc = splt.visbrain_plot( |
47 | | - mesh=mesh, tex=mean_curv, caption="mean curvature", cblabel="mean curvature" |
48 | | -) |
49 | | -visb_sc.preview() |
50 | | - |
51 | | -############################################################################### |
52 | | -# Plot Gauss curvature |
53 | | -visb_sc = splt.visbrain_plot( |
54 | | - mesh=mesh, |
55 | | - tex=gaussian_curv, |
56 | | - caption="Gaussian curvature", |
57 | | - cblabel="Gaussian curvature", |
58 | | - cmap="hot", |
59 | | -) |
60 | | -visb_sc.preview() |
61 | | - |
62 | 46 | ############################################################################### |
63 | 47 | # Decomposition of the curvatures into ShapeIndex and Curvedness |
64 | 48 | # Based on 'Surface shape and curvature scales |
65 | 49 | # Jan JKoenderink & Andrea Jvan Doorn' |
66 | 50 | shapeIndex, curvedness = scurv.decompose_curvature(PrincipalCurvatures) |
67 | 51 |
|
68 | | -############################################################################### |
69 | | -# Plot of ShapeIndex and Curvedness |
70 | | -visb_sc = splt.visbrain_plot( |
71 | | - mesh=mesh, |
72 | | - tex=shapeIndex, |
73 | | - caption="ShapeIndex", |
74 | | - cblabel="ShapeIndex", |
75 | | - cmap="coolwarm", |
76 | | -) |
77 | | -visb_sc.preview() |
78 | | - |
79 | | -visb_sc = splt.visbrain_plot( |
80 | | - mesh=mesh, tex=curvedness, caption="Curvedness", cblabel="Curvedness", cmap="hot" |
81 | | -) |
82 | | -visb_sc.preview() |
83 | | - |
84 | | - |
85 | 52 | ############################################################################### |
86 | 53 | # Estimation error on the principal curvature length |
87 | 54 | K = [1, 0] |
|
137 | 104 | k1_relative_change = abs((k1_analytic - k1_estim) / k1_analytic) |
138 | 105 | k1_absolute_change = abs((k1_analytic - k1_estim)) |
139 | 106 |
|
140 | | -############################################################################### |
141 | | -# Error plot |
142 | | - |
143 | | -visb_sc = splt.visbrain_plot( |
144 | | - mesh=quadric, |
145 | | - tex=k_mean_absolute_change, |
146 | | - caption="K_mean absolute error", |
147 | | - cblabel="K_mean absolute error", |
148 | | -) |
149 | | -visb_sc.preview() |
150 | | - |
151 | 107 | ############################################################################### |
152 | 108 | # Estimation error on the curvature directions |
153 | 109 | # commented because there is a bug: |
|
190 | 146 | ) |
191 | 147 | angular_error_1 = 180 * angular_error_1 / np.pi |
192 | 148 |
|
| 149 | +############################################################################# |
| 150 | +# VISUALIZATION USING EXTERNAL TOOLS |
| 151 | +############################################################################# |
| 152 | +# import visbrain # visu using visbrain |
| 153 | +# Plot mean curvature |
| 154 | +# visb_sc = splt.visbrain_plot( |
| 155 | +# mesh=mesh, |
| 156 | +# tex=mean_curv, |
| 157 | +# caption="mean curvature", |
| 158 | +# cblabel="mean curvature" |
| 159 | +# ) |
| 160 | +# visb_sc.preview() |
| 161 | +############################################################################# |
| 162 | +# # Plot Gauss curvature |
| 163 | +# visb_sc = splt.visbrain_plot( |
| 164 | +# mesh=mesh, |
| 165 | +# tex=gaussian_curv, |
| 166 | +# caption="Gaussian curvature", |
| 167 | +# cblabel="Gaussian curvature", |
| 168 | +# cmap="hot", |
| 169 | +# ) |
| 170 | +# visb_sc.preview() |
| 171 | +############################################################################### |
| 172 | +# Plot of ShapeIndex and Curvedness |
| 173 | +# visb_sc = splt.visbrain_plot( |
| 174 | +# mesh=mesh, |
| 175 | +# tex=shapeIndex, |
| 176 | +# caption="ShapeIndex", |
| 177 | +# cblabel="ShapeIndex", |
| 178 | +# cmap="coolwarm", |
| 179 | +# ) |
| 180 | +# visb_sc.preview() |
| 181 | +# |
| 182 | +# visb_sc = splt.visbrain_plot( |
| 183 | +# mesh=mesh, |
| 184 | +# tex=curvedness, |
| 185 | +# caption="Curvedness", |
| 186 | +# cblabel="Curvedness", |
| 187 | +# cmap="hot" |
| 188 | +# ) |
| 189 | +# visb_sc.preview() |
193 | 190 | ############################################################################### |
194 | 191 | # Error plot |
195 | | - |
196 | | -visb_sc = splt.visbrain_plot( |
197 | | - mesh=quadric, |
198 | | - tex=angular_error_0, |
199 | | - caption="Angular error 0", |
200 | | - cblabel="Angular error 0", |
201 | | -) |
202 | | -visb_sc.preview() |
203 | | - |
204 | | -visb_sc = splt.visbrain_plot( |
205 | | - mesh=quadric, |
206 | | - tex=angular_error_1, |
207 | | - caption="Angular error 1", |
208 | | - cblabel="Angular error 1", |
209 | | -) |
210 | | -visb_sc.preview() |
| 192 | +# visb_sc = splt.visbrain_plot( |
| 193 | +# mesh=quadric, |
| 194 | +# tex=k_mean_absolute_change, |
| 195 | +# caption="K_mean absolute error", |
| 196 | +# cblabel="K_mean absolute error", |
| 197 | +# ) |
| 198 | +# visb_sc.preview() |
| 199 | +# ############################################################################### |
| 200 | +# # Error plot |
| 201 | +# visb_sc = splt.visbrain_plot( |
| 202 | +# mesh=quadric, |
| 203 | +# tex=angular_error_0, |
| 204 | +# caption="Angular error 0", |
| 205 | +# cblabel="Angular error 0", |
| 206 | +# ) |
| 207 | +# visb_sc.preview() |
| 208 | +# |
| 209 | +# visb_sc = splt.visbrain_plot( |
| 210 | +# mesh=quadric, |
| 211 | +# tex=angular_error_1, |
| 212 | +# caption="Angular error 1", |
| 213 | +# cblabel="Angular error 1", |
| 214 | +# ) |
| 215 | +# visb_sc.preview() |
0 commit comments