pyvista-support icon indicating copy to clipboard operation
pyvista-support copied to clipboard

Voxelized model is skewed and looks weird :-( pls help

Open ferbrjan opened this issue 3 years ago • 8 comments

Hi there,

I ran into a problem while trying to voxelize some .obj files that I created using meshlab. The goal was to extract some objects from 3D models, voxelize those objects and the maps, label each of the objects by a corresponding class and then put the objects back into the voxelized map. Therefore the result would be a voxelized environment with labeled objects. Everything was going good until I ran into a problem with the voxelize function. Everytime I voxelize any format (.obj, .stl, .ply) I always recieve model that is slightly skewed. I am setting the check_surface to False since my map and objects all contain holes etc.

Please help :-(

My super simple code:

surface = pv.read("file.obj") surface voxels = pv.voxelize(surface, density=0.1,check_surface=False) voxels voxels.save("file.vtk")

.obj file visualization Snímek obrazovky 2021-08-04 v 12 57 04

voxelization using online voxelizer (my desired result) Snímek obrazovky 2021-08-04 v 12 58 25

voxelization using pyvista.voxelize() Snímek obrazovky 2021-08-04 v 13 00 59

ferbrjan avatar Aug 04 '21 11:08 ferbrjan

What does the original import look like and after voxelisation? How did the final plot get done?

RichardScottOZ avatar Aug 04 '21 11:08 RichardScottOZ

this is how the import looks like after surface.plot() Snímek obrazovky 2021-08-04 v 13 17 08

this is how the voxelistaion looks like after voxels.plot() Snímek obrazovky 2021-08-04 v 13 19 23

ferbrjan avatar Aug 04 '21 11:08 ferbrjan

It makes no sense that a online voxelizer on https://drububu.com/miscellaneous/voxelizer does the job correctly, binvox at https://www.patrickmin.com/binvox/ also works great, but this voxelize function creates this weird looking shapes :(

And since I would need to run this on 500+ files, online voxelizer is not an option, and binvox does not keep the information about the location of the object in the map

ferbrjan avatar Aug 04 '21 11:08 ferbrjan

What does a different density do, 0.01 etc?

RichardScottOZ avatar Aug 04 '21 11:08 RichardScottOZ

My mesh is in metric units, that means that density 1 would mean a voxel of size 1m x 1m x 1m, 0.1 means voxel of 10cm x 10cm x 10cm , 0.01 would mean voxel size of 1cm x 1cm x 1cm.... At least that's how I understand it.

ferbrjan avatar Aug 04 '21 11:08 ferbrjan

Yes, so what does it look like at higher res?

RichardScottOZ avatar Aug 04 '21 11:08 RichardScottOZ

Really similar from what I've tried... It's better with higher resolution, but I need the resolution to be at the 10x10x10cm, since the map itself is otherwise greater than 10GB. Also as you can see on the screenshot from https://drububu.com/miscellaneous/voxelizer the resolution is sufficient for the model. (the length of the longest side model is approx 23m and the longest side is split into 189 voxels which is more or less 12x12x12cm)

ferbrjan avatar Aug 04 '21 11:08 ferbrjan

If it is the right type PVGeo has a voxelise points function, too.

RichardScottOZ avatar Aug 04 '21 12:08 RichardScottOZ