# image_output

Python API: `depthai_nodes.node.parsers.image_output`

## Classes

| Name | Description |
| --- | --- |
| [`ImageOutputParser`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser) | Parser class for image-to-image models (e.g. DnCNN3, zero-dce etc.) where the output is a modified image (denoised, enhanced etc.). |

### class `ImageOutputParser`

```python
class ImageOutputParser(BaseParser)
```

Parser class for image-to-image models (e.g. DnCNN3, zero-dce etc.) where the output is a modified image (denoised, enhanced
etc.).

> **Note**
> Emits `dai.ImgFrame` messages. Image message containing the output image e.g. denoised or enhanced images.

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If the output is not 3- or 4-dimensional. |
| `ValueError` | If the number of output layers is not 1. |

Attributes

| Name | Description |
| --- | --- |
| `output_is_bgr` | Flag indicating if the output image is in BGR (Blue-Green-Red) format. |
| `output_layer_name` | Name of the output layer relevant to the parser. |

Methods

| Name | Description |
| --- | --- |
| [`__init__`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-__init__) | Initialize the parser node. |
| [`build`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-build) | Configures the parser. |
| [`compute`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-compute) | Compute parser results from extracted tensors without sending messages. |
| [`emit`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-emit) | Create a `dai.ImgFrame` message and send it on `out`. |
| [`extract`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-extract) | Select and dequantize the model tensors needed for parsing. |
| [`run`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-run) | Read queued network outputs, parse them, and emit results while running. |
| [`setBGROutput`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-setBGROutput) | Sets the flag indicating that output image is in BGR. |
| [`setOutputLayerName`](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/image_output.md#image_output-Classes-ImageOutputParser-setOutputLayerName) | Sets the name of the output layer. |

#### method `__init__`

```python
def __init__(output_layer_name: str = '', output_is_bgr: bool = False)
```

Initialize the parser node.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_name` | `str` | Output tensor name. An empty name selects the only available output layer during extraction. | `''` |
| `output_is_bgr` | `bool` | Whether the output image uses BGR channel order. | `False` |

#### method `build`

```python
def build(head_config: dict[str, Any]) -> ImageOutputParser
```

Configures the parser.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `head_config` | `dict[str, Any]` | The head configuration for the parser. | required |

Returns

| Type | Description |
| --- | --- |
| `ImageOutputParser` | The parser object with the head configuration set. |

#### static method `compute`

```python
def compute(output_image)
```

Compute parser results from extracted tensors without sending messages.

> **Note**
> Uses [depthai_nodes.node.parsers.utils.image_output.compute_image_output](https://docs.luxonis.com/software-v3/ai-inference/inference/depthai-nodes/depthai-nodes-api-reference/node/parsers/utils/image_output.md#image_output-Functions-compute_image_output); see that helper for tensor layout and validation details.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_image` |  | CHW or HWC tensor, optionally preceded by a singleton batch dimension. | required |

Returns

| Type | Description |
| --- | --- |
|  | A uint8 array with the same channel layout as the unbatched input. Values are min-max scaled to [0, 255]; constant tensors become zero. |

#### method `emit`

```python
def emit(output: dai.NNData, image)
```

Create a `dai.ImgFrame` message and send it on `out`.

Copies source timestamps and sequence number, and carries the source image transformation when present.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |
| `image` |  | Image array returned by `compute()`. | required |

#### method `extract`

```python
def extract(output: dai.NNData)
```

Select and dequantize the model tensors needed for parsing.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output` | `dai.NNData` | Neural network output carrying tensors and source timestamps, sequence number, and optional image transformation. | required |

Returns

| Type | Description |
| --- | --- |
|  | Dequantized image tensor retaining the model tensor layout. |

Raises

| Type | Description |
| --- | --- |
| `ValueError` | If no output name is configured and the message does not contain exactly one layer, or configured class requirements are not met. |

#### method `run`

```python
def run()
```

Read queued network outputs, parse them, and emit results while running.

The pipeline invokes this processing loop. It exits when the input queue closes or the node stops.

#### method `setBGROutput`

```python
def setBGROutput()
```

Sets the flag indicating that output image is in BGR.

#### method `setOutputLayerName`

```python
def setOutputLayerName(output_layer_name: str)
```

Sets the name of the output layer.

Args

| Name | Type | Description | Default |
| --- | --- | --- | --- |
| `output_layer_name` | `str` | The name of the output layer. | required |
