# image_output

Python API: `depthai_nodes.node.parsers.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.).

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

Raises

 * `ValueError`: If the output is not 3- or 4-dimensional.
 * `ValueError`: If the number of output layers is not 1.

#### Methods

##### init

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

Initialize the parser node.

Parameters

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

##### build

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

Configures the parser.

Parameters

 * `head_config` (`dict[str, Any]`): The head configuration for the parser.

Returns

 * `ImageOutputParser`: The parser object with the head configuration set.

##### 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); see that helper for tensor layout and validation details.

Parameters

 * `output_image`: CHW or HWC tensor, optionally preceded by a singleton batch dimension.

Returns

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

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

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.
 * `image`: Image array returned by `compute()`.

##### extract

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

Select and dequantize the model tensors needed for parsing.

Parameters

 * `output` (`dai.NNData`): Neural network output carrying tensors and source timestamps, sequence number, and optional image
   transformation.

Returns

 * Dequantized image tensor retaining the model tensor layout.

Raises

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

##### run

```python
def run(self):
```

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.

##### setBGROutput

```python
def setBGROutput(self):
```

Sets the flag indicating that output image is in BGR.

##### setOutputLayerName

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

Sets the name of the output layer.

Parameters

 * `output_layer_name` (`str`): The name of the output layer.

#### Attributes

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