Let's say I have some composite 3D graphics of various shapes. For simplicity, let's say these are just two capsules, like below:
myShapes = {CapsuleShape[{{-0.002997, 0., 0.}, {0.002997, 0., 0.}}, 2.997],
CapsuleShape[{{5.22693, 0.954974, 0.945536}, {5.23274, 0.956034,
0.946586}}, 2.997]}
Graphics3D[myShapes, ViewPoint -> Front,
ViewProjection -> "Orthographic"]
Now, from that orthographic projection, I'd like to get a binary image of the "foreground" pixels visible from the projection, so that I can get 2D ComponentMeasurements[] (like area, circularity, etc.)
We can use Jen's function from this answer to get a black "shadow", which seems promising, but such shadow is still a Graphics3D[] object, so it does not seem very useful (but it's cool!):
How could I go about this?
Thanks!
Note: Ideally, the projection should respect the dimensions of the original graphics (say, the diameter/shape of the capsules), but I'm assuming the orthographic projection would take care of that(?)





Clear[plot, img]; myShapes = {CapsuleShape[{{-0.002997, 0., 0.}, {0.002997, 0., 0.}}, 2.997], CapsuleShape[{{5.22693, 0.954974, 0.945536}, {5.23274, 0.956034, 0.946586}}, 2.997]}; plot = Graphics3D[{Black, myShapes}, ViewProjection -> "Orthographic", ViewPoint -> {0, 1, 0}, Boxed -> False, PlotRangePadding -> 1.2, PlotRange -> Full]; img = ImportString[ExportString[plot, "PNG"]]– cvgmt Jul 17 '22 at 03:10ImportString[ExportString[plot, "PNG"]]could be replaced byRasterize– SHuisman Jan 25 '24 at 16:42