Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
voxelgrid_highest
**USE POINTS**
points_random
n: int
Number of points to be sampled.
"""
if name in ALL_SAMPLERS:
sampler = ALL_SAMPLERS[name](pyntcloud=self, **kwargs)
sampler.extract_info()
sample = sampler.compute()
if as_PyntCloud:
return PyntCloud(sample)
return sample
else:
raise ValueError("Unsupported sampling method. Check docstring")
0 on voxels further than 2 * voxel side.
target_size : [int, int, int], optional (Default [30, 30, 30])
Dimensions of voxelgrid in case voxelize is True.
Returns
-------
feature_vector : ndarray
(target_size[0], target_size[1], target_size[2])
Raises
------
ValueError: if 3D format is not valid.
"""
point_cloud = PyntCloud.from_file(path)
if point_cloud.mesh is not None:
point_cloud = PyntCloud(point_cloud.get_sample(
"mesh_random", n=n_sampling))
if voxelize:
vgrid_id = point_cloud.add_structure("voxelgrid", x_y_z=target_size)
voxelgrid = point_cloud.structures[vgrid_id]
if voxel_mode == "binary":
feature_vector = voxelgrid.get_feature_vector(mode="binary")
elif voxel_mode == "density":
feature_vector = voxelgrid.get_feature_vector(mode="density")
elif voxel_mode == "TDF":
feature_vector = voxelgrid.get_feature_vector(mode="TDF")
else:
Dimensions of voxelgrid in case voxelize is True.
Returns
-------
feature_vector : ndarray
(target_size[0], target_size[1], target_size[2])
Raises
------
ValueError: if 3D format is not valid.
"""
point_cloud = PyntCloud.from_file(path)
if point_cloud.mesh is not None:
point_cloud = PyntCloud(point_cloud.get_sample(
"mesh_random", n=n_sampling))
if voxelize:
vgrid_id = point_cloud.add_structure("voxelgrid", x_y_z=target_size)
voxelgrid = point_cloud.structures[vgrid_id]
if voxel_mode == "binary":
feature_vector = voxelgrid.get_feature_vector(mode="binary")
elif voxel_mode == "density":
feature_vector = voxelgrid.get_feature_vector(mode="density")
elif voxel_mode == "TDF":
feature_vector = voxelgrid.get_feature_vector(mode="TDF")
else:
raise ValueError("Invalid mode; available modes are: {}".format(
{"binary", "density", "TDF"}))
and_return: boolean, optional
Default: False
If True, return a list with the splits.
save_format: str, optional
Default: "ply"
Extension used to save the generated PyntClouds.
Must be of one of the formats present in pyntcloud.io.TO
save_path: str, optional
Default: "."
Path where the PyntClouds will be saved.
"""
scalar_field = self.points[scalar_field]
splits = {x: PyntCloud(self.points.loc[scalar_field == x]) for x in scalar_field.unique()}
if not os.path.exists(save_path):
os.makedirs(save_path)
for key, val in splits.items():
val.to_file("{}/{}.{}".format(save_path, key, save_format))
if and_return:
return splits