---
title: "DepthImage"
---
<!-- DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/docs/website.rs -->

A depth image, i.e. as captured by a depth camera.

Each pixel corresponds to a depth value in units specified by [`components.DepthMeter`](https://rerun.io/docs/reference/types/components/depth_meter).

## Fields
### Required
* `buffer`: [`ImageBuffer`](https://rerun.io/docs/reference/types/components/image_buffer.md)
* `format`: [`ImageFormat`](https://rerun.io/docs/reference/types/components/image_format.md)

### Optional
* `meter`: [`DepthMeter`](https://rerun.io/docs/reference/types/components/depth_meter.md)
* `colormap`: [`Colormap`](https://rerun.io/docs/reference/types/components/colormap.md)
* `depth_range`: [`ValueRange`](https://rerun.io/docs/reference/types/components/value_range.md)
* `point_fill_ratio`: [`FillRatio`](https://rerun.io/docs/reference/types/components/fill_ratio.md)
* `draw_order`: [`DrawOrder`](https://rerun.io/docs/reference/types/components/draw_order.md)
* `magnification_filter`: [`MagnificationFilter`](https://rerun.io/docs/reference/types/components/magnification_filter.md)


## Can be shown in
* [Spatial2DView](https://rerun.io/docs/reference/types/views/spatial2d_view.md)
* [Spatial3DView](https://rerun.io/docs/reference/types/views/spatial3d_view.md) (if logged under a projection)
* [DataframeView](https://rerun.io/docs/reference/types/views/dataframe_view.md)

## API reference links
 * 🌊 [C++ API docs for `DepthImage`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1archetypes_1_1DepthImage.html)
 * 🐍 [Python API docs for `DepthImage`](https://ref.rerun.io/docs/python/stable/common/archetypes#rerun.archetypes.DepthImage)
 * 🦀 [Rust API docs for `DepthImage`](https://docs.rs/rerun/latest/rerun/archetypes/struct.DepthImage.html)

## Examples

### Simple example

```python
"""Create and log a depth image."""

import numpy as np

import rerun as rr

depth_image = 65535 * np.ones((200, 300), dtype=np.uint16)
depth_image[50:150, 50:150] = 20000
depth_image[130:180, 100:280] = 45000

rr.init("rerun_example_depth_image_simple", spawn=True)

# Log the tensor, assigning names to each dimension
rr.log("depth", rr.DepthImage(depth_image, meter=10_000.0))
```

<picture data-inline-viewer="snippets/archetypes/depth_image_simple">
  <source media="(max-width: 480px)" srcset="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/480w.png">
  <source media="(max-width: 768px)" srcset="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/768w.png">
  <source media="(max-width: 1024px)" srcset="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/1024w.png">
  <source media="(max-width: 1200px)" srcset="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/1200w.png">
  <img src="https://static.rerun.io/depth_image_simple/77a6fa4f938a742bdc7c5350f668c4f31eed4d01/full.png">
</picture>

### Depth to 3D example

```python
"""Create and log a depth image and pinhole camera."""

import numpy as np

import rerun as rr

depth_image = 65535 * np.ones((200, 300), dtype=np.uint16)
depth_image[50:150, 50:150] = 20000
depth_image[130:180, 100:280] = 45000

rr.init("rerun_example_depth_image_3d", spawn=True)

# If we log a pinhole camera model, the depth gets automatically
# back-projected to 3D
rr.log(
    "world/camera",
    rr.Pinhole(
        width=depth_image.shape[1],
        height=depth_image.shape[0],
        focal_length=200,
    ),
)

# Log the tensor.
rr.log(
    "world/camera/depth",
    rr.DepthImage(depth_image, meter=10_000.0, colormap="viridis"),
)
```

<picture data-inline-viewer="snippets/archetypes/depth_image_3d">
  <source media="(max-width: 480px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/480w.png">
  <source media="(max-width: 768px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/768w.png">
  <source media="(max-width: 1024px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/1024w.png">
  <source media="(max-width: 1200px)" srcset="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/1200w.png">
  <img src="https://static.rerun.io/depth_image_3d/924e9d4d6a39d63d4fdece82582855fdaa62d15e/full.png">
</picture>

