From surface data to image data#
In this notebook we will turn surfaces into binary and label images.
import napari_process_points_and_surfaces as nppas
import vedo
mesh = vedo.load("../../data/branchoid.ply")
surface = nppas.to_napari_surface_data(mesh)
surface
nppas.SurfaceTuple
|
Binary volumes#
A common task is to fill a volume to create a binary image stack.
binary_image = nppas.surface_to_binary_volume(surface)
binary_image
|
Labeled surface voxels#
We can also sample points from the surface and turn these points into a label image.
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)
point_labels = nppas.points_to_labels(point_cloud)
point_labels
|
point_labels[50]
|
These labels can also be turned into points again.
centroids = nppas.labels_to_centroids(point_labels)
centroids[:10]
[(26.0, 44.0, 47.0),
(26.0, 44.0, 48.0),
(26.0, 44.0, 50.0),
(26.0, 44.0, 52.0),
(26.0, 44.0, 54.0),
(26.0, 45.0, 46.0),
(26.0, 45.0, 48.0),
(26.0, 45.0, 50.0),
(26.0, 45.0, 52.0),
(26.0, 45.0, 55.0)]