3D Voxel mask from geometry/ does plane intersect with volume
8 views (last 30 days)
Hi Does anyone know if there is a way to efficently convert from geometry (for example a quadrilateral defined by its corners) to a binary voxel mask. I want somthing like the function poly2mask but which will work in 3D and return true voxel values if the input plane or line touches the voxel.
My ultimate aim is to use this with the output from voronoi() to generate x-ray CT like data for finite element modelling.
I've seen this: https://uk.mathworks.com/matlabcentral/fileexchange/37863-blended-3d-poly2mask But i want to be able to cope with polys that arent aligned with the voxel planes.
Ahmet Cecen on 10 Nov 2016
Edited: Ahmet Cecen on 10 Nov 2016
Well, the first problem you define is slightly more problematic, but the actual task you mention is easier.
A Voronoi tessellation is simply an L2 distance boundary. This means if you generate your random centers, you can voxelize it by assigning each voxel to the closest center.
It would look something like:
[X,Y,Z] = meshgrid(xgv,ygv,zgv)
Space = [X(:),Y(:),Z(:)];
IDX = knnsearch(CENTERS,Space);
Voxelized = reshape(IDX,sizeofVolume);