# apply_depth_colormap

Python API: `depthai_nodes.node.apply_depth_colormap`

## Classes

### ApplyDepthColormap

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).

Parameters

 * `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

##### init

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

Initialize the image-processing node.

Parameters

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

##### build

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

Connect the input depth stream to the node.

Parameters

 * `frame` (`dai.Node.Output`): Upstream output producing a RAW depth dai.ImgFrame.

Returns

 * `ApplyDepthColormap`: The configured node instance.

##### process

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

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

Parameters

 * `frame` (`dai.Buffer`): RAW depth or disparity ImgFrame. Non-positive pixels become black. Frames without a usable
   normalization range produce an all-black image.

Raises

 * `TypeError`: If the input is not an ImgFrame with a RAW format.

##### setColormap

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

Set the color mapping applied to depth images.

Parameters

 * `colormapValue` (`int | np.ndarray`): OpenCV colormap enum value or a custom OpenCV-compatible LUT.

Raises

 * `ValueError`: If a custom colormap is not a uint8 array of shape `(256, 1, 3)`.

##### setPercentileRange

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

Set the percentile clipping range used for normalization.

Parameters

 * `low` (`float`): Lower percentile in the range [0, 100).
 * `high` (`float`): Upper percentile in the range (0, 100].

Raises

 * `ValueError`: If the bounds do not satisfy `0 <= low < high <= 100`.
