daavoo / pyntcloud

pyntcloud is a Python library for working with 3D point clouds.
http://pyntcloud.readthedocs.io
MIT License
1.39k stars 221 forks source link

Argument to know which point goes in which voxel #298

Closed mserouar closed 3 years ago

mserouar commented 3 years ago

Hello,

I don't know if it exists yet, but why not extracting in a file the xyz position of each points and their linked voxel. To know which points contain a voxel. Maybe in add_structure.

Congrats

daavoo commented 3 years ago

Hola! Thanks for the question.

There is already a scalar field that contains that information. You would need to first add a voxelgrid:

voxelgrid_id = could.add_structure("voxelgrid", n_x=64, n_y=64, n_z=64)

And then add the scalar field voxel_n:

cloud.add_scalar_field("voxel_n", voxelgrid_id=voxelgrid_id)

This will add a new column to the points dataframe (in addition to the x, y, z) containing the unique voxel id for each point. You can then save the information to a file in the format you want.

daavoo commented 3 years ago

Feel free to re-open if you consider that the question has not been properly answered

mserouar commented 1 year ago

Just a quick thing, actually I'm more interested in linking voxels centers coordinates (in grids) with voxel class and then join with original point cloud. Is there a way to do it ?