ColorTransform 算子

Operator Library: Color

Operator ColorTransform 将输入的 RGB 数据流转换为具有加权分量的 RGB 数据流。 该转换通过输入 RGB 向量与 3x3 矩阵相乘来实现。

转换矩阵由参数 Coefficients 定义。 此参数是一个包含双精度系数的 3x3 矩阵。 以下公式表示转换算法。

计算时使用定点精度值。 参数 Precision 和 Resolution 指定乘法精度。

  • Precision 定义用于编码系数的位数。

  • Resolution 定义系数的小数位数。

例如,8 位的 Precision 和 6 位的 Resolution 将产生以下范围内的系数 .

如果输入链接是有符号的,或者字段参数 Coefficients 设置为 static,则允许使用有符号值作为系数。 当字段参数 Coefficients 设置为 dynamic(即可以在运行时更改转换系数)时,输出链接始终是有符号的。 其中一个精度位用作符号位。

提供矩阵乘法的结果。 结果会四舍五入到最近的整数值。 输出 Bit Width 是根据输入 Bit Width 和参数设置自动确定的。

[注意] 静态参数可减少资源占用

如果将参数 Coefficients 设置为 static,则 operator 所需的 FPGA 资源更少。

I/O Property

Property 值
Operator Type O
Input Link I,图像数据输入
Output Link O, image data input

支持的 Link Format

Link Parameter Input Link I Output Link O
Bit Width [3, 54] 无符号,[6, 54] 有符号 auto1
Arithmetic {unsigned, signed} auto
Parallelism any as I
Kernel Columns 1 as I
Kernel Rows 1 as I
Img Protocol {VALT_IMAGE2D, VALT_LINE1D, VALT_PIXEL0D} as I
Color Format VAF_COLOR as I
Color Flavor FL_RGB as I
Max. Img Width any as I
Max. Img Height any as I

1

输出 Bit Width 是根据输入 Bit Width 和参数设置自动确定的。

参数

分辨率
键入 静态参数
默认 8
范围 auto

Defines the number of fractional bits of a coefficient. The range depends on the input Bit Width and the value of parameter Precision. Mind the following limitations:

Resolution > 0

Precision > Resolution

Precision + Resolution <= 32

精度
键入 静态参数
默认 16
范围 auto

定义对整个系数进行编码的位数 - 包括分辨率位和符号位。 范围取决于输入 Bit Width 和 Precision 参数的值。请注意以下限制:

Resolution > 0

Precision > Resolution

Precision + Resolution <= 32

Coefficients
键入 动态/静态读/写参数
默认 单位矩阵
范围 所有系数均为无符号: 任意系数有符号:

使用单位变换初始化的系数矩阵。 operator 将矩阵的所有系数视为有符号数。这些系数是双精度数。

使用示例

以下示例展示了 operator ColorTransform 的使用方法: