# apply_depth_colormap

Python API: `depthai_nodes.node.apply_depth_colormap`

## Classes

| Name | Description |
| --- | --- |
| [`ApplyDepthColormap`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap) | A host node that applies a colormap to a depth map using percentile-based normalization to reduce flicker. |

### class `ApplyDepthColormap`

```python
class ApplyDepthColormap(BaseHostNode)
```

A host node that applies a colormap to a depth map using percentile-based normalization to reduce flicker.

Works with RAW 2D dai.ImgFrame outputs such as stereo.depth and stereo.disparity frames. Percentile normalization is typically
more beneficial for stereo.depth since disparity often has a fixed output range.

Invalid depth values (<= 0) are ignored when computing percentiles and are rendered as black in the output.

Inputs:

 * `frame : dai.ImgFrame`: Input message containing a 2D array to be colorized.

Outputs:

 * `output : dai.ImgFrame`: Colorized output frame (3-channel BGR).

Args

| Name | Description |
| --- | --- |
| `colormapValue` | OpenCV colormap enum (e.g. cv2.COLORMAP_JET) or a custom OpenCV-compatible colormap LUT. Default is cv2.COLORMAP_JET. |
| `pLow` | Lower normalization percentile in [0, 100). Default 2.0. |
| `pHigh` | Upper normalization percentile in (0, 100]. Default 98.0. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap-__init__) | Initialize the image-processing node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap-build) | Connect the input depth stream to the node. |
| [`process`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap-process) | Colorize valid depth samples and emit an image with source metadata. |
| [`setColormap`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap-setColormap) | Set the color mapping applied to depth images. |
| [`setPercentileRange`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/apply_depth_colormap.md#apply_depth_colormap-Classes-ApplyDepthColormap-setPercentileRange) | Set the percentile clipping range used for normalization. |

#### method `__init__`

```python
def __init__(
    colormapValue: int | np.ndarray = cv2.COLORMAP_JET,
    pLow: float = 2.0,
    pHigh: float = 98.0,
)
```

Initialize the image-processing node.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `colormapValue` | `int | np.ndarray` | OpenCV colormap enum (e.g. cv2.COLORMAP_JET) or a custom OpenCV-compatible colormap LUT. Default is cv2.COLORMAP_JET. | `cv2.COLORMAP_JET` |
| `pLow` | `float` | Lower normalization percentile in [0, 100). Default 2.0. | `2.0` |
| `pHigh` | `float` | Upper normalization percentile in (0, 100]. Default 98.0. | `98.0` |

#### method `build`

```python
def build(frame: dai.Node.Output) -> ApplyDepthColormap
```

Connect the input depth stream to the node.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `frame` | `dai.Node.Output` | Upstream output producing a RAW depth dai.ImgFrame. | required |

Returns

| Type | Description |
| --- | --- |
| `ApplyDepthColormap` | The configured node instance. |

#### method `process`

```python
def process(frame: dai.Buffer)
```

Colorize valid depth samples and emit an image with source metadata.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `frame` | `dai.Buffer` | RAW depth or disparity ImgFrame. Non-positive pixels become black. Frames without a usable normalization range produce an all-black image. | required |

Raises

| Type | Description |
| --- | --- |
| `TypeError` | If the input is not an ImgFrame with a RAW format. |

#### method `setColormap`

```python
def setColormap(colormapValue: int | np.ndarray)
```

Set the color mapping applied to depth images.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `colormapValue` | `int | np.ndarray` | OpenCV colormap enum value or a custom OpenCV-compatible LUT. | required |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If a custom colormap is not a uint8 array of shape `(256, 1, 3)`. |

#### method `setPercentileRange`

```python
def setPercentileRange(low: float, high: float)
```

Set the percentile clipping range used for normalization.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `low` | `float` | Lower percentile in the range [0, 100). | required |
| `high` | `float` | Upper percentile in the range (0, 100]. | required |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the bounds do not satisfy `0 <= low < high <= 100`. |
