Converting points and surfaces#
In this notebook we will sample points from a surface and convert the point cloud back into a surface.
import napari_process_points_and_surfaces as nppas
import vedo
import napari
viewer = napari.Viewer(ndisplay=3)
def hide_all(viewer):
for layer in viewer.layers:
layer.visible = False
def show_all(viewer):
for layer in viewer.layers:
layer.visible = True
mesh = vedo.load("../../data/branchoid.ply")
surface = nppas.to_napari_surface_data(mesh)
surface_layer = viewer.add_surface(surface)
napari.utils.nbscreenshot(viewer)
Creating point clouds#
We can create a point cloud from the surface. The points are located on the surface and not inside the volume.
point_cloud = nppas.sample_points_from_surface(surface, distance_fraction=0.01)
point_cloud
array([[26. , 44. , 46.5],
[26. , 43.5, 48. ],
[26. , 43.5, 50. ],
...,
[74.5, 55. , 52. ],
[74.5, 56. , 49. ],
[74.5, 56. , 51. ]], dtype=float32)
hide_all(viewer)
points_layer = viewer.add_points(point_cloud, size=1)
napari.utils.nbscreenshot(viewer)