My goal is to produce a 3D dataset, from a scene of simple transformed shapes. The idea is that this data serves as a ground truth for some tomographic reconstruction problems. (For this, it is especially nice that with Mathematica, Ellipsoid
, Cuboid
and other 3D primitives remain algebraic up to the point of discretization.)
Ideally, I would like to partition the 3D space into voxels (small cuboids), and compute per voxel how much of it is filled by a shape. This does not have to be very precise, I'm happy already if the value is $1$ if it contains something and $0$ otherwise.
However, I do not manage to get the shapes into a discrete dataset of values. So far, I tried something simple:
B = Ball[{10,10,10}, 2];
reg = TransformedRegion[B, ShearingTransform[Pi/5, {1, 0, 0}, {0, 0, 1}]]
DiscretizeGraphics[Graphics3D[reg]];
which produces a triangular mesh (instead of a uniform) for an ellipsoid (sheared ball).
For 2D problems I managed to get grid data from converting the Graphics
to grayscale, and subsequently to ImageData
. In 3D that doesn't work.
It seems like a relatively simple thing to do, but after a few hours of bugging the documentation, I still did not find a solution. All suggestions are much appreciated.
reg
? Then tryBoundaryDiscretizeRegion[reg]
orDiscretizeRegion[reg]
.Graphics3D
objects represent only the surfaces of the regions (for performance reasons). $\endgroup$RegionImage[]
? $\endgroup$ImageMesh[]
if you want to see a voxelization. $\endgroup$