---
title: "Image3D"
language: "en"
type: "Symbol"
summary: "Image3D[data] represents a 3D image with pixel values given by the array data. Image3D[{image1, image2, ...}] creates a 3D image from a list of 2D images. Image3D[obj,  type] creates a 3D image of the specified data type."
keywords: 
- image3D
- 3D image
- volume
- volumetric data
- volumetric display
- volumetric rendering
- voxel
- voxel data
- volumetric pixel
- volumetric imaging
- 3D dicom
- 3D mri
canonical_url: "https://reference.wolfram.com/language/ref/Image3D.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "3D Images"
    link: "https://reference.wolfram.com/language/guide/3DImages.en.md"
  - 
    title: "Image Processing & Analysis"
    link: "https://reference.wolfram.com/language/guide/ImageProcessing.en.md"
  - 
    title: "Image Representation"
    link: "https://reference.wolfram.com/language/guide/ImageRepresentation.en.md"
  - 
    title: "Creating & Importing Images"
    link: "https://reference.wolfram.com/language/guide/CreatingAndImportingImages.en.md"
  - 
    title: "Image Computation for Microscopy"
    link: "https://reference.wolfram.com/language/guide/ImageComputationForMicroscopy.en.md"
related_functions: 
  - 
    title: "Raster3D"
    link: "https://reference.wolfram.com/language/ref/Raster3D.en.md"
  - 
    title: "Image"
    link: "https://reference.wolfram.com/language/ref/Image.en.md"
  - 
    title: "ArrayPlot3D"
    link: "https://reference.wolfram.com/language/ref/ArrayPlot3D.en.md"
  - 
    title: "Import"
    link: "https://reference.wolfram.com/language/ref/Import.en.md"
  - 
    title: "ImageData"
    link: "https://reference.wolfram.com/language/ref/ImageData.en.md"
  - 
    title: "Image3DSlices"
    link: "https://reference.wolfram.com/language/ref/Image3DSlices.en.md"
  - 
    title: "Image3DProjection"
    link: "https://reference.wolfram.com/language/ref/Image3DProjection.en.md"
  - 
    title: "ImageType"
    link: "https://reference.wolfram.com/language/ref/ImageType.en.md"
  - 
    title: "ImageDimensions"
    link: "https://reference.wolfram.com/language/ref/ImageDimensions.en.md"
  - 
    title: "Graphics3D"
    link: "https://reference.wolfram.com/language/ref/Graphics3D.en.md"
  - 
    title: "ImageQ"
    link: "https://reference.wolfram.com/language/ref/ImageQ.en.md"
---
# Image3D

Image3D[data] represents a 3D image with pixel values given by the array data.

Image3D[{image1, image2, …}] creates a 3D image from a list of 2D images.

Image3D[obj, "type"] creates a 3D image of the specified data type.

## Details and Options

* ``Image3D``, also known as a volumetric image or a 3D volume, is a regular 3-dimensional grid of voxels,  typically generated from a sequence of 2D images acquired by MRI or CT scanners.

* ``Image3D`` displays in a notebook as a rendered volume.

[image]

* In ``Image3D[data]``, by default the first three dimensions correspond to slices, rows, and columns of the 3D image, respectively. Slices are enumerated from top to bottom, rows from back to front, and columns from left to right.

* An ``Image3D`` object with ``ImageDimensions`` of ``{width, depth, height}`` is placed in the 3D space so that in a position ``{x, y, z}`` given in the standard image coordinate system, ``x`` runs from ``0`` to ``width``, ``y`` runs from ``0`` to ``depth``, and ``z`` runs from 0 to ``height``. The position ``{0, 0, 0}`` corresponds to the bottom-left front corner.

* ``Image3D[{image1, image2, …, imageheight}]`` will have ``ImageDimensions`` of ``{width, depth, height}``, where ``ImageDimensions[imagej]`` is ``{width, depth}`` for each of the 2D images, stacked from top to bottom. »

* In ``Image3D[data]``, each element of ``data`` can specify values for any number of channels.

* Elements of ``data`` can be one of the following:

|                 |                                                    |
| --------------- | -------------------------------------------------- |
| v               | rendered as gray level from 0 (black) to 1 (white) |
| {r, g, b}       | rendered as red, green, blue values from 0 to 1    |
| {c1, c2, c3, …} | channel values rendered by equally spaced hues     |
| color           | specific color                                     |

* The input array ``data`` can be given as a ``List``, ``NumericArray``, ``SparseArray``, etc.

* ``Image3D[data]`` by default allows values in any range, but displays only values between 0 and 1.

* ``Image3D[data, "type"]`` can be used to create a 3D image of a specified data type. Values in ``data`` are coerced to the specified type by rounding or clipping. By default, ``"Real32"`` is assumed.

* Possible settings for ``"type"`` include:

|          |                                |
| -------- | ------------------------------ |
| "Bit"    | integer 0 or 1                 |
| "Byte"   | integer 0 through 255          |
| "Bit16"  | integer 0 through 65535        |
| "Real32" | single-precision real (32-bit) |
| "Real64" | double-precision real (64-bit) |

* ``Image3D[image, "type"]`` can be used to convert between types.

* ``Image3D[{i1, i2, …}]`` converts all images to the largest type among the input images.

* ``Image3D[{i1, i2, …}, "type"]`` converts all images to the specified type.

* ``Image3D`` takes the following options:

|                 |           |                                             |
| --------------- | --------- | ------------------------------------------- |
| ColorSpace      | Automatic | what color space to assume for the data     |
| ImageResolution | Automatic | the resolution to use when exporting        |
| ImageSize       | Automatic | display size of the volume                  |
| Interleaving    | True      | whether to assume channels are interleaved  |
| Magnification   | Automatic | how to magnify the displayed volume         |
| MetaInformation | {}        | meta-information associated with the volume |

* ``Image3D`` also accepts the following ``Raster3D`` options:

|                |           |                                             |
| -------------- | --------- | ------------------------------------------- |
| ClipRange      | None      | cut away a rectangular region from the view |
| ColorFunction  | Automatic | how to translate data values into colors    |
| Method         | Automatic | options for rendering the color cells       |

* ``Image3D`` also accepts the following ``Graphics3D`` options:

|                  |                 |                                                                          |
| :--------------- | :-------------- | :----------------------------------------------------------------------- |
| AlignmentPoint   | Center          | the default point in the graphic to align with                           |
| Axes             | False           | whether to draw axes                                                     |
| AxesEdge         | Automatic       | on which edges to put axes                                               |
| AxesLabel        | None            | axes labels                                                              |
| AxesOrigin       | Automatic       | where axes should cross                                                  |
| AxesStyle        | {}              | graphics directives to specify the style for axes                        |
| Background       | None            | background color for the Image3D                                         |
| BaselinePosition | Automatic       | how to align with a surrounding text baseline                            |
| Boxed            | False           | whether to draw the bounding box                                         |
| BoxRatios        | Automatic       | bounding 3D box ratios                                                   |
| BoxStyle         | {}              | style specifications for the box                                         |
| ClipPlanes       | None            | clipping planes                                                          |
| ClipPlanesStyle  | Automatic       | style specifications for clipping planes                                 |
| RotationAction   | "Fit"           | how to render after interactive rotation                                 |
| SphericalRegion  | False           | whether to make the circumscribing sphere fit in the final display area  |
| ViewAngle        | Automatic       | angle of the field of view                                               |
| ViewCenter       | Automatic       | point to display at the center                                           |
| ViewMatrix       | Automatic       | explicit transformation matrix                                           |
| ViewPoint        | {1.3, -2.4, 2.} | viewing position                                                         |
| ViewRange        | All             | range of viewing distances to include                                    |
| ViewVector       | Automatic       | position and direction of a simulated camera                             |
| ViewVertical     | {0, 0, 1}       | direction to make vertical                                               |

* With the setting ``BoxRatios -> {sx, sy, sz}``, the ``Image3D`` is rendered in a box of the given side-length ratios.

* With ``ColorFunction -> cf``, color and opacity of each voxel can be specified. An interactive color function editor is available via the ``Image3D`` contextual (right-click) menu.

* ``ColorSpace -> "space"`` specifies that values in the data should be interpreted as coordinates in a particular color space. ``ColorSpace -> Automatic`` treats values as arbitrary channel intensities.

* Bit images always have ``ColorSpace`` set to ``Automatic``.

* With the setting ``ColorSpace -> "RGB"``, data given as ``{r, g, b, a}`` is taken to include an opacity value ``a``.

* With the default setting ``Interleaving -> True``, ``Image3D[data, …]`` takes ``data`` to be a 3D array of lists ``{c1, c2, …}`` of channel values.

* With ``Interleaving -> False``, ``Image3D[data, …]`` takes ``data`` to be a list ``{v1, v2, …}`` of 3D arrays of values for each channel.

* Explicit settings for ``ImageSize`` determine the absolute size at which ``Image3D`` should be displayed.

* With ``ImageSize -> Automatic``, the size at which the 3D image should be displayed is determined by the setting for ``Magnification``.

* A setting ``Magnification -> m`` specifies that each displayed voxel in ``Image3D`` is magnified by a factor of ``m``.

* With ``Magnification -> Automatic``, smaller 3D images are typically displayed at larger magnifications, and large 3D images are reduced to fit within available notebook or other display areas.

* ``Image3D[Image3D[…], opts]`` effectively resets the options for an ``Image3D``.

* ``ImageDimensions``, ``ImageChannels``, and ``ImageType`` find information on the structure of a 3D image.

* ``Image3D[Raster3D[…]]`` converts a ``Raster3D`` object to a 3D image.

* Arithmetic and statistical operations such as ``Log``, ``Plus`` and ``Mean`` can work directly with images.

* ``Information`` for ``Image3D`` may include the following properties:

|                   |                                                    |
| ----------------- | -------------------------------------------------- |
| "Channels"        | number of image channels                           |
| "ColorSpace"      | the color space to assume for data                 |
| "DataType"        | underlying data type                               |
| "ImageDimensions" | pixel dimensions                                   |
| "Interleaving"    | whether data is stored interleaved                 |
| "Transparency"    | whether the image has transparency (alpha) channel |

---

## Background & Context

``Image3D`` provides unified symbolic representation for a variety of digital 3D image formats. In particular, an ``Image3D`` object contains a three-dimensional array of values (or lists of values) that represent a 3D raster image. 3D images are commonly encountered in medical imaging, geographic mapping, and scientific visualization.

The data inside a 3D image may take on a variety of values depending on if the image is binary, grayscale, RGB, etc. The first three dimensions of an ``Image3D`` correspond to slices, rows, and columns, respectively. Slices are enumerated from top to bottom, rows from back to front, and columns from left to right.

``Image3D`` objects are visualized using a set of techniques collectively known as volume rendering that display a projection of discretely sampled 3D data values. Given an ``Image3D`` containing a regular volumetric grid, each volume element is known as a voxel and is represented by a single value (or list of values).

Upon output, a 3D image formats as a picture of a projection of the image (not as a 3D array of values). ``Image3D`` objects may be exported to a variety of standard image formats using ``Export``, and images in a number of formats may be imported as ``Image3D`` objects using ``Import``. Slices of a 3D image may be stored in separate images file formats or different frames of a file format that support multiple frames (e.g. TIFF, DICOM, etc.).

Applying ``Image3D`` to a list of 2D images creates a 3D image. The function ``Show`` can be used to combine 3D vector graphics with ``Image3D`` objects. A ``Raster3D`` graphics expression may be converted to a 3D image by applying the function ``Image3D`` to it.

The array of pixel values in a 3D image may be obtained using ``ImageData``. ``ImageDimensions`` gives the pixel dimensions of the raster associated with an ``Image3D`` object. ``ImageType`` gives a label representing the number type used internally to represent each pixel of a 3D image. ``ImageChannels`` gives the number of channels the 3D image contains.

Options useful for ``Image3D`` objects include ``ColorSpace``, ``Interleaving``, ``ImageSize``, and ``Magnification``. Other options useful for 3D rendering include ``BoxRatios``, ``ColorFunction``, ``ColorFunctionScaling``, and ``Background``.

---

## Examples (19)

### Basic Examples (4)

Create a real-value 3D image from numbers in the range 0 to 1:

```wl
In[1]:= Image3D[RandomReal[1, {5, 10, 10}]]

Out[1]= [image]
```

---

Create a three-channel 3D image:

```wl
In[1]:= Image3D[RandomReal[1, {5, 10, 10, 3}]]

Out[1]= [image]
```

---

Create a 3D image from a stack of images:

```wl
In[1]:= Image3D[{[image], [image], [image]}]

Out[1]= [image]
```

---

Import a list of images as a 3D volume:

```wl
In[1]:= Import["ExampleData/CTengine.tiff", "Image3D"]

Out[1]= [image]
```

### Scope (4)

#### Creating a 3D Image (2)

Create from a 3D region:

```wl
In[1]:= RegionImage[KnotData["Trefoil", "Region"]]

Out[1]= [image]
```

---

Create a 3D volume from an elevation map:

```wl
In[1]:=
everest = [image];
data = ImageData[ImageReflect[everest, Top -> Bottom]];
data3D = Map[# Table[UnitStep[50 # - k], {k, 50}]&, data, {-1}];

In[2]:= Image3D[Reverse@Transpose[data3D, {3, 2, 1}], ColorFunction -> "DarkTerrainOpacity"]

Out[2]= [image]
```

#### Arithmetic & Statistical Operations (2)

Multiply two volumes to highlight a region of interest:

```wl
In[1]:= [image]×[image]

Out[1]= [image]
```

---

Compute statistical measures on images:

```wl
In[1]:= i = Import["ExampleData/CTengine.tiff", "Image3D"]

Out[1]= [image]

In[2]:= stats = {Total, Min, Max, Mean, Median, StandardDeviation};Dataset[AssociationThread[Text /@ stats -> Through[stats[i]]]]

Out[2]= Dataset[<>]
```

### Options (3)

#### Background (1)

Use a black background for volume rendering:

```wl
In[1]:= Image3D[ExampleData[{"TestImage3D", "MRknee"}], ColorFunction -> "XRay", Background -> Black]

Out[1]= [image]
```

#### BoxRatios (1)

By default, ``BoxRatios`` is set to the dimensions ratios of the 3D volume:

```wl
In[1]:= i = ExampleData[{"TestImage3D", "CThead"}]

Out[1]= [image]
```

Set ``BoxRatios`` to the ratios of the object:

```wl
In[2]:= Image3D[i, BoxRatios -> {1, 1, 1}]

Out[2]= [image]
```

#### ColorFunction (1)

Default rendering of a grayscale volume:

```wl
In[1]:= engine = ExampleData[{"TestImage3D", "CTengine"}]

Out[1]= [image]
```

A gray color function with linear opacity is commonly used for rendering of grayscale volumes:

```wl
In[2]:= Image3D[engine, ColorFunction -> "GrayLevelOpacity"]

Out[2]= [image]
```

Use a gray color function with constant opacity:

```wl
In[3]:= Image3D[engine, ColorFunction -> (GrayLevel[#, .005]&)]

Out[3]= [image]
```

Use one of the predefined color functions:

```wl
In[4]:= Labeled[Image3D[engine, ColorFunction -> #], #]& /@ {"XRay", "HighRange", "LowRange", "WhiteBlackOpacity", "SunsetColorsOpacity", "RainbowOpacity"}

Out[4]= [image]
```

Use a customized color function:

```wl
In[5]:= Image3D[engine, ColorFunction -> (Append[Blend[{LightBlue, Blue, Orange}, #], #]&)]

Out[5]= [image]
```

With a fully opaque color function, only the box surface is visible:

```wl
In[6]:= Image3D[engine, ColorFunction -> GrayLevel]

Out[6]= [image]
```

### Applications (1)

Display a motion pattern by blurring an animation in the temporal dimension:

```wl
In[1]:= anim = {[image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image], [image]};
```

Convert the animation frames into an ``Image3D`` object:

```wl
In[2]:= image3D = Image3D[anim, ColorFunction -> "GrayLevelOpacity", BoxRatios -> {1, 1, 1 / 4}]

Out[2]= [image]
```

Blur along the slices to get a temporal interpolation:

```wl
In[3]:= Image3DSlices[Blur[image3D, {3, 0, 0}], {10}][[1]]

Out[3]= [image]
```

### Properties & Relations (2)

Use ``Show`` to combine 3D vector graphics and ``Image3D`` objects:

```wl
In[1]:=
i = [image];
{w, d, h} = ImageDimensions[i];
s = 20;
Show[i, Graphics3D[{RGBColor[0, 0, 1, 0.2], Polygon[{{0, 0, s}, {0, d, s}, {w, d, s}, {w, 0, s}}]}]]

Out[1]= [image]
```

---

``ArrayPlot3D`` displays the data as discrete elements:

```wl
In[1]:=
ca = CellularAutomaton[
	<|"GrowthCases" -> {1}, "Dimension" -> 3, "Neighborhood" -> 7|>, {{{{1}}}, 0}, {{{5}}}];

In[2]:= {Image3D[ca], ArrayPlot3D[ca]}

Out[2]= {[image], [image]}
```

### Possible Issues (2)

Placing a grayscale image into an ``Image3D`` object will change the overall visualization:

```wl
In[1]:= i = [image];

In[2]:= Image3D[{i}]

Out[2]= [image]
```

Use ``GrayLevel`` color function to see similar gray values:

```wl
In[3]:= Image3D[{i}, ColorFunction -> GrayLevel]

Out[3]= [image]
```

---

White background is not suitable when rendering binary images with a gray color function:

```wl
In[1]:= Image3D[DiskMatrix[{10, 10, 10}], "Bit", ColorFunction -> "GrayLevelOpacity"]

Out[1]= [image]
```

Use a black background:

```wl
In[2]:= Image3D[DiskMatrix[{10, 10, 10}], "Bit", ColorFunction -> "GrayLevelOpacity", Background -> Black]

Out[2]= [image]
```

Adding a box can also help make the 3D object more visible:

```wl
In[3]:= Image3D[DiskMatrix[{10, 10, 10}], "Bit", ColorFunction -> "GrayLevelOpacity", Background -> Black, Boxed -> True]

Out[3]= [image]
```

### Neat Examples (3)

Evolution of a 3D cellular automaton:

```wl
In[1]:=
Image3D[#, ImageSize -> 150] &  /@ 
 CellularAutomaton[{14, {2, 1}, {1, 1, 1}}, {{{{1}}}, 0}, 8]

Out[1]= [image]
```

---

Evolution of a Game of Life cellular automaton:

```wl
In[1]:= Image3D[CellularAutomaton[{224, {2, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}, {SeedRandom[1];RandomInteger[1, {15, 15}], 0}, 50]]

Out[1]= [image]
```

---

Blurred evolution of a discrete 2D cellular automaton, reminiscent of diffusion processes in the continuous domain:

```wl
In[1]:= Blur[Image3D[CellularAutomaton[{52212111133224, {3, {{2, 2, 2}, {2, 1, 2}, {2, 2, 2}}}, {1, 1}}, {SeedRandom[1];RandomInteger[1, {15, 15}], 0}, 150], ImageSize -> 100], 3]

Out[1]= [image]
```

## See Also

* [`Raster3D`](https://reference.wolfram.com/language/ref/Raster3D.en.md)
* [`Image`](https://reference.wolfram.com/language/ref/Image.en.md)
* [`ArrayPlot3D`](https://reference.wolfram.com/language/ref/ArrayPlot3D.en.md)
* [`Import`](https://reference.wolfram.com/language/ref/Import.en.md)
* [`ImageData`](https://reference.wolfram.com/language/ref/ImageData.en.md)
* [`Image3DSlices`](https://reference.wolfram.com/language/ref/Image3DSlices.en.md)
* [`Image3DProjection`](https://reference.wolfram.com/language/ref/Image3DProjection.en.md)
* [`ImageType`](https://reference.wolfram.com/language/ref/ImageType.en.md)
* [`ImageDimensions`](https://reference.wolfram.com/language/ref/ImageDimensions.en.md)
* [`Graphics3D`](https://reference.wolfram.com/language/ref/Graphics3D.en.md)
* [`ImageQ`](https://reference.wolfram.com/language/ref/ImageQ.en.md)

## Related Guides

* [3D Images](https://reference.wolfram.com/language/guide/3DImages.en.md)
* [Image Processing & Analysis](https://reference.wolfram.com/language/guide/ImageProcessing.en.md)
* [Image Representation](https://reference.wolfram.com/language/guide/ImageRepresentation.en.md)
* [Creating & Importing Images](https://reference.wolfram.com/language/guide/CreatingAndImportingImages.en.md)
* [Image Computation for Microscopy](https://reference.wolfram.com/language/guide/ImageComputationForMicroscopy.en.md)

## Related Links

* [An Elementary Introduction to the Wolfram LanguageArrays, or Lists of Lists](https://www.wolfram.com/language/elementary-introduction/13-arrays-or-lists-of-lists.html)
* [An Elementary Introduction to the Wolfram LanguageMore about Pure Functions](https://www.wolfram.com/language/elementary-introduction/29-more-about-pure-functions.html)

## History

* [Introduced in 2012 (9.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn90.en.md) \| [Updated in 2014 (10.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn100.en.md) ▪ [2017 (11.1)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn111.en.md) ▪ [2019 (12.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn120.en.md)