# How to convert Image3D object into Graphics3D object and vice versa?

There are some rendering options (for example, Lighting) which are associated with the Graphics3D objects. I cannot apply these options for an Image3D object (for example, ExampleData[{"TestImage3D", "MRknee"}]).

Is there any way to convert an Image3D object into Graphics3D object, apply some lighting options and convert back to Image3D object?

• Graphics is vector graphics containing geometric primitives. Image is simply a raster--a grid of pixels. You cannot, in general, recover geometric figures merely from their representation on a grid. Apr 28, 2016 at 15:58
• This is closely related to mathematica.stackexchange.com/questions/91998/…
– M.R.
Apr 28, 2016 at 20:15

Simply use Show. This creates a Graphics3D containing a Raster3D.

In general, expressions convertible to Graphics are converted with Show. This works for images, 3D images, graphs, and possibly other things I've forgotten about.

But I'm not sure Lighting is ever used in the rendering of 3D images, regardless of whether they are contained in an Image3D or a Graphics3D through Raster3D ...

As for the reverse conversion, that is not possible for arbitrary Graphics3D. But you can always extract a Raster3D and transplant its contents into an Image3D.

For 2D images, just use Image[Graphics[...]].

• Note that "Image[Raster[...]] converts a Raster object to an image" and "Image3D[Raster3D[...]] converts a Raster3D object to a 3D image" (from the "Details and Options" fields of Image and Image3D Documentaion pages). As opposed to this, Image[Graphics[...]] uses Rasterize under the hood. Apr 28, 2016 at 16:17

For Graphics3D -> Image3D:

This answer: https://mathematica.stackexchange.com/a/33277/6804 gives an approach that rasterizes individual 2D slices at different heights and stacks them into a 3d image.

Of course you need to select a resolution, the conversion will not be lossless in general (and I don't know what would happen when the Graphics3D object is a Show@Image3D... maybe you get a resampling, or nothing).