Issue during voxelization of a model stl

Hi all!

I have to convert a surface model stl into a voxelized mask, with 1s inside and 0s outside. It is important that the mask has the same dimensions and voxel size as another volume I want to register with. In Matlab the available functions don’t allow to specify voxel size and this is very important for me. Getting inspired by this post: Voxelization of mesh, I follow these steps:

  1. Import stl and convert into segmentation node by right clicking on the model entry in the data module.
  2. Import the other volume, and in the volume section specify the voxel size and center it.
  3. Go to the transform model, and create a new transformation which moves the segmentation so that the crucial parts of it overlap the other volume. This step may not be needed.
  4. Go to the Segmentation Module, and select export the segmentation as a labelmap, indicating as reference volume the other one, so that the output voxelized mask has the same dimensions and voxel size.
  5. Then, go to the volume section, select the just created volume, and convert to scalar volume.

I’d like to know if these steps are well or if there is another way to do it better. The stl model sometimes appears to be bigger than the object in the other volume, when it shouldn’t be. And other thing: should the stl model have some basis features (i.g. closed surface, filled inside etc.)?

You can do it a bit simpler:

  • Load the STL as segmentation: in “Add data” dialog, choose “Segmentation” in description column
  • Create master volume of at the desired resolution: Go to Segment Editor module, click on Specify geometry button (next to Master volume selector), select your input mesh as source geometry, specify voxel size (spacing values) and click OK
  • Create binary labelmap representation: go to Data module, right-click on the segmentation and choose Export visible segments to binary labelmap
1 Like