Voxelise STL files using mesh voxelisation

조회 수: 28 (최근 30일)
Zehra Ese
Zehra Ese 2020년 6월 17일
답변: TED MOSBY 2025년 3월 18일
Hi, I would like to voxelise a 3d mesh constuction (STL file), which works very well with the mesh voxelisation from the file exchange (https://de.mathworks.com/matlabcentral/fileexchange/27390-mesh-voxelisation). This program is able to voxelise the imported STL file in a given grid, which is definable by the user in three dimensions [gridX,gridY,gridZ]. The voxelsize in this way is defined by the STL model size and the given number of voxels. I would like to define the voxelsize by myself, fo example 1mm and the number if voxels for each dimension should be adjust to the model size. For example the model is a cube with the dimension of 3x4x5 mm. With a cubic voxelsize of 1 mm, we would get 3 voxels in X direction, 4 voxels in Y direction and 5 voxels in Z directeion, respectively. Is there a way to do like this?
  댓글 수: 2
Jan Marxen
Jan Marxen 2021년 4월 11일
If you found something like that please tell me. Thank you
Zhihao Wei
Zhihao Wei 2023년 7월 5일
I am also looking for stl2voxel matlab code, pls let me know.

댓글을 달려면 로그인하십시오.

답변 (1개)

TED MOSBY
TED MOSBY 2025년 3월 18일
Hi Zehra,
You can voxelize an STL mesh at a fixed voxel size (e.g., 1 mm) using the “VOXELISE” function from the File Exchange. The key idea is to:
  • Define a 1 mm grid based on the model's dimensions (3×4×5 mm) so you get exactly 3 voxels in X, 4 in Y, and 5 in Z (total 60).
  • Call "VOXELISE" with those grid coordinates (e.g., voxel centers at 0.5, 1.5, … in each dimension) plus the mesh to find which cells are inside the model.
  • Draw each true cell as a 1×1×1 cube (red faces, black edges) so you see the full 3×4×5 array of voxels.
I have attached an example script as reference. As I dont have your STL file I simulated it by creating a cuboid mesh. Feel free to adjust according to your use case.
Hope this helps!

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by