MATLAB Answers

3D Voxel mask from geometry/ does plane intersect with volume

4 views (last 30 days)
Michael
Michael on 10 Nov 2016
Commented: M.S. Khan on 4 Aug 2019
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.

Accepted Answer

Ahmet Cecen
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);
  3 Comments
M.S. Khan
M.S. Khan on 4 Aug 2019
[X,Y,Z] = meshgrid(xgv,ygv,zgv)
Space = [X(:),Y(:),Z(:)];
IDX = knnsearch(CENTERS,Space);
Voxelized = reshape(IDX,sizeofVolume);
where are values of xgv, ygv and zgv?
could you plz explain the terminology of this coding to me. will be very thankful

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by