Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions examples/example_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,3 @@
mesh.bounding_cylinder.volume,
mesh.bounding_sphere.volume,
)


46 changes: 28 additions & 18 deletions examples/example_curvature.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@
)
angular_error_1 = 180 * angular_error_1 / np.pi


#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################

import slam.plot as splt

vertices = mesh.vertices
Expand All @@ -161,10 +163,12 @@
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta),0],
[np.sin(theta), np.cos(theta),0],
[0, 0, 1],])
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1], ])
vertices_translate = np.dot(rot_z, vertices_translate.T).T

# Plot Mean Curvature
display_settings = {}
display_settings['colorbar_label'] = 'Mean Curvature'
mesh_data = {}
Expand All @@ -174,70 +178,76 @@
intensity_data = {}
intensity_data['values'] = mean_curv
intensity_data["mode"] = "vertex"
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_1.png")

# Plot Gaussian Curvature
mesh_data['title'] = 'example_mesh.gii Gaussian Curvature'
intensity_data['values'] = gaussian_curv
display_settings['colorbar_label'] = 'Gaussian Curvature'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_2.png")

# Plot Shape Index
mesh_data['title'] = 'example_mesh.gii Shape Index'
intensity_data['values'] = shapeIndex
display_settings['colorbar_label'] = 'Shape Index'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_3.png")

# Plot Curvedness
mesh_data['title'] = 'example_mesh.gii Curvedness'
intensity_data['values'] = curvedness
display_settings['colorbar_label'] = 'Curvedness'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_4.png")

# Plot Quadric K Mean Absolute Change
mesh_data['vertices'] = quadric.vertices
mesh_data['faces'] = quadric.faces
mesh_data['title'] = 'Quadric K Mean Absolute Change'
intensity_data['values'] = k_mean_absolute_change
display_settings['colorbar_label'] = 'K Mean Absolute Change'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_5.png")

# Plot Quadric Angular Error 0
mesh_data['title'] = 'Quadric Angular Error 0'
intensity_data['values'] = angular_error_0
display_settings['colorbar_label'] = 'Angular Error 0'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
Fig.write_image("example_curvature_6.png")

mesh_data['title'] = ('Quadric Angular Error 1')
# Plot Quadric Angular Error 1
mesh_data['title'] = 'Quadric Angular Error 1'
intensity_data['values'] = angular_error_1
display_settings['colorbar_label'] = 'Angular Error 1'
Fig = splt.mes3d_projection(
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
#Fig.show()
# Fig.show()
Fig.write_image("example_curvature_7.png")
87 changes: 53 additions & 34 deletions examples/example_differential_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# importation of slam modules
import slam.io as sio
import slam.differential_geometry as sdg

import numpy as np
###############################################################################
# loading an examplar mesh and corresponding texture
mesh_file = "../examples/data/example_mesh.gii"
Expand Down Expand Up @@ -52,37 +52,56 @@
print(norm_grad)

#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################
# # import visbrain # visu using visbrain
# visb_sc = splt.visbrain_plot(
# mesh=mesh,
# tex=tex.darray[0],
# caption="mesh with curvature", cblabel="curvature"
# )
# visb_sc.preview()
# ###############################################################################
# # show the smoothed mesh
# visb_sc = splt.visbrain_plot(
# mesh=s_mesh,
# caption="smoothed mesh"
# )
# visb_sc.preview()
# ###############################################################################
# # show the norm of the gradient of the curvature
# visb_sc = splt.visbrain_plot(
# mesh=mesh,
# tex=norm_grad,
# caption="norm of the gradient of curvature",
# cblabel="gradient magnitude",
# )
# visb_sc.preview()
# ###############################################################################
# # show the depth potential function
# visb_sc = splt.visbrain_plot(
# mesh=mesh,
# tex=dpf[0],
# caption="depth potential function",
# cblabel="dpf"
# )
# visb_sc.preview()

import slam.plot as splt

vertices = mesh.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1], ])
vertices_translate = np.dot(rot_z, vertices_translate.T).T

# Plot Original Mesh
display_settings = {}
display_settings['colorbar_label'] = 'Curvature'
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh.faces
mesh_data['title'] = 'example_mesh.gii Mean Curvature'
intensity_data = {}
intensity_data['values'] = tex.darray[0]
intensity_data["mode"] = "vertex"
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
# Fig.show()
Fig.write_image("example_differential_geometry_1.png")

# Show the Norm of the Gradient of the Curvature
display_settings = {}
display_settings['colorbar_label'] = 'Gradient Magnitude'
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh.faces
mesh_data['title'] = 'example_mesh.gii Norm of the Gradient of Curvature'
intensity_data = {}
intensity_data['values'] = norm_grad
intensity_data["mode"] = "vertex"
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
# Fig.show()
Fig.write_image("example_differential_geometry_2.png")
58 changes: 53 additions & 5 deletions examples/example_distortion.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,61 @@
edge_diff = sdst.edge_length_difference(mesh, mesh_s)
edge_diff


#############################################################################
# VISUALIZATION USING EXTERNAL TOOLS
# VISUALIZATION USING INTERNAL TOOLS
#############################################################################

import slam.plot as splt

# # Visualization of the original mesh
# visb_sc = splt.visbrain_plot(mesh=mesh, caption="original mesh")
# visb_sc.preview()
vertices = mesh.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
theta = np.pi / 2
rot_x = np.array([[1, 0, 0],
[0, np.cos(theta), -np.sin(theta)],
[0, np.sin(theta), np.cos(theta)]])
vertices_translate = np.dot(rot_x, vertices_translate.T).T
rot_z = np.array([[np.cos(theta), -np.sin(theta), 0],
[np.sin(theta), np.cos(theta), 0],
[0, 0, 1],])
vertices_translate = np.dot(rot_z, vertices_translate.T).T
display_settings = {}
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh.faces
mesh_data['title'] = 'example_mesh.gii Original Mesh'
intensity_data = None
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
# Fig.show()
Fig.write_image("example_distortion_1.png")

# ############################################################################
# # Visualization of the smoothed mesh
# visb_sc = splt.visbrain_plot(mesh=mesh_s, caption="smoothed mesh")
# visb_sc.preview()

vertices = mesh_s.vertices
# center the vertices
vertices = vertices - np.mean(vertices, axis=0)
vertices_translate = np.copy(vertices)
# rotate the vertices
vertices_translate = np.dot(rot_x, vertices_translate.T).T
vertices_translate = np.dot(rot_z, vertices_translate.T).T

display_settings = {}
mesh_data = {}
mesh_data['vertices'] = vertices_translate
mesh_data['faces'] = mesh_s.faces
mesh_data['title'] = 'example_mesh.gii Smoothed Mesh'
intensity_data = None
Fig = splt.mesh_projection(
mesh_data=mesh_data,
intensity_data=intensity_data,
display_settings=display_settings)
# Fig.show()
Fig.write_image("example_distortion_2.png")
Loading
Loading