Note
Go to the end to download the full example code.
Vertex voronoi example in slam¶
# Authors:
# Guillaume Auzias <guillaume.auzias@univ-amu.fr>
# Julien Barrès <julien.barres@etu.univ-amu.fr>
# License: MIT
# sphinx_gallery_thumbnail_number = 2
Importation of slam modules
import slam.io as sio
import slam.vertex_voronoi as svv
import numpy as np
Load a mesh
mesh = sio.load_mesh("../examples/data/example_mesh.gii")
Compute the vertex voronoi
vert_vor = svv.vertex_voronoi(mesh)
-percent polygon with obtuse angle 29.4067067927773
vertex voronoi is a numpy array of the same size as mesh.vertices
print(mesh.vertices.shape)
print(vert_vor.shape)
(2328, 3)
(2328,)
vertex voronoi corresponds to the “area of vertices”. It is the sum of 1/3 of the triangles to which the vertex belongs. So the sum of vertex voronoi is equal to the area of the entire mesh
print(np.sum(vert_vor) - mesh.area)
0.0
VISUALIZATION USING plotly¶
import slam.plot as splt
Visualization
display_settings = {}
mesh_data = {}
mesh_data['vertices'] = mesh.vertices
mesh_data['faces'] = mesh.faces
mesh_data['title'] = 'example_mesh.gii'
intensity_data = {}
intensity_data['values'] = vert_vor
intensity_data["mode"] = "vertex"
fig = splt.plot_mesh(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
fig.show()
fig
Total running time of the script: (0 minutes 2.649 seconds)