Say I generate some Graphics3D object, e.g.:

Graphics3D[{Red, Sphere[{0, 0, 0}, 1], Blue, Sphere[{1, 0, 0}, 1]}]

Does it make sense to ask for the color of a "voxel" / volumetric pixel in this image? In other words, is it possible to call some three-dimensional analogue of PixelValue or ImageValue to determine what region in the 3D box is red or blue? What might happen at the intersection of the red and blue spheres?

Shouldn't this be possible given that I can select a subregion of the graphics3D object to display in some bounding box? And if so, couldn't I just make the bounding box around the area of interest arbitrarily small, save the output as a TIFF and call ImageValue[] or PixelValue[] on the center of the TIFF image? Surely there's a better way to proceed?

Update: george2079 hits the nail on the head in my opinion with his suggestion that we should think about this problem as a problem of making a 3D implementation of Rasterize[]. A problem that may or may not be relevant, though, is that most of the Graphics3D objects are hollow. To see this, try zooming around a Graphics3D output using some amazing code written by the user rm -rf: Implementing a first person view of 3D objects in a scene

  • 1
    $\begingroup$ PixelValue and ImageValue already work with voxels, of course, because you can use them with Image3D images. However, there's no easy way to convert a Graphics3D object to an Image3D one, so your question is still valid. $\endgroup$
    – cormullion
    Commented May 20, 2013 at 8:09
  • $\begingroup$ it makes perfect sense. What you are after is a 3d version of Rasterize. (maybe there is a trick to pull a 2d section out of 3d graphic then apply rasterize?) $\endgroup$
    – george2079
    Commented May 20, 2013 at 11:53
  • $\begingroup$ @george2079 The trouble, I suspect, will be that the Graphics3D objects are hollow. $\endgroup$
    – QuadraticU
    Commented May 20, 2013 at 13:13

1 Answer 1


so following my comment you can do this..

dz = .01; i3d = 
 Graphics3D[Cylinder[{{0, 0, 0}, {1, 2, 0}}, 1], Boxed -> False, 
  ViewPoint -> {0, 0, Infinity}, 
  PlotRange -> {All, All, {z - dz, z + dz}}]] ] , {z, -1, 1, dz}]];
ImageData[i3d][[100, 100, 100]]

The problem as QuadraticU noted is your 3D "objects" are only rended as surfaces, and so everything is effectively hollow.

I guess if you can live with a restricted set of primatives you could set about creating you own primatives that did an insideness test and manually scan to generate the voxel map.

this may be useful if you want to go there.. Efficiently determining if 3D points are within a surface composed of polygons


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.