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

6 ビュー (過去 30 日間)
Michael
Michael 2016 年 11 月 10 日
コメント済み: George Abrahams 2024 年 1 月 12 日
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
Ahmet Cecen 2016 年 11 月 10 日
編集済み: Ahmet Cecen 2016 年 11 月 10 日
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);
  4 件のコメント
M.S. Khan
M.S. Khan 2019 年 8 月 4 日
[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
George Abrahams
George Abrahams 2024 年 1 月 12 日
Hi @M.S. Khan. What @Ahmet Cecen provided is a simple method of generating a Voronoi diagram in a 3D volume. Hopefully my example below is clearer.
% Options.
numberOfVoronoiRegions = 10;
volumeSize = [ 100, 150, 200 ];
% Create an Nx3 matrix of all voxel coordinates in the volume. Each row
% gives the subscripts for a voxel.
volumeXvalues = 1 : volumeSize(1);
volumeYvalues = 1 : volumeSize(2);
volumeZvalues = 1 : volumeSize(3);
[ X, Y, Z ] = ndgrid( volumeXvalues, volumeYvalues, volumeZvalues );
voxelCoordinates = [ X(:), Y(:), Z(:) ];
% Randomly select some voxels as Voronoi seeds, i.e., the center of the
% regions or cells.
rng( 1 )
voronoiSeedCoordinates = ...
datasample( voxelCoordinates, numberOfVoronoiRegions );
% Create the Voronoi diagram by find the closest Voronoi seed to each
% voxel, and then reshaping this to again form a volume.
indexOfClosestSeed = knnsearch( voronoiSeedCoordinates, voxelCoordinates );
voronoiDiagram = reshape( indexOfClosestSeed, volumeSize );
% Find the boundaries where the label value changes, i.e., the edges.
% Uncomment the line below if you want the "outer walls" of the volume.
% voronoiDiagram = padarray( voronoiDiagram, [1 1 1], 0 );
[ gX, gY, gZ ] = gradient( voronoiDiagram );
voronoiBoundaries = ( gX .^2 + gY .^2 + gZ .^2 ) > 0;
% Show the Voronoi boundaries.
isosurface( voronoiBoundaries )
axis tight equal

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVoronoi Diagram についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by