Converts image bit depth.
This kernel converts an image from some source bit-depth to another bit-depth as described by the table below. If the input value is unsigned the shift must be in zeros. If the input value is signed, the shift used must be an arithmetic shift. The columns in the table below are the output types and the rows are the input types. The API version on which conversion is supported is also listed. (An X denotes an invalid operation.)
I/O | U8 | U16 | S16 | U32 | S32 |
U8 | X | | 1.0 | | |
U16 | | X | X | | |
S16 | 1.0 | X | X | | |
U32 | | | | X | X |
S32 | | | | X | X |
Conversion Type
The table below identifies the conversion types for the allowed bith depth conversions.
From | To | Conversion Type |
U8 | S16 | Up-conversion |
S16 | U8 | Down-conversion |
Convert Policy
Down-conversions with VX_CONVERT_POLICY_WRAP
follow this equation:
output(x,y) = ((uint8)(input(x,y) >> shift));
Down-conversions with VX_CONVERT_POLICY_SATURATE
follow this equation:
int16 value = input(x,y) >> shift;
value = value < 0 ? 0 : value;
value = value > 255 ? 255 : value;
output(x,y) = (uint8)value;
Up-conversions ignore the policy and perform this operation:
output(x,y) = ((int16)input(x,y)) << shift;
The valid values for 'shift' are as specified below, all other values produce undefined behavior.
[Graph] Creates a bit-depth conversion node.
- Parameters
-
[in] | graph | The reference to the graph. |
[in] | input | The input image. |
[out] | output | The output image. |
[in] | policy | A scalar containing a VX_TYPE_ENUM of the vx_convert_policy_e enumeration. |
[in] | shift | A scalar containing a VX_TYPE_INT32 of the shift value. |
- Returns
vx_node
.
- Return values
-
vx_node | A node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus |
[Immediate] Converts the input images bit-depth into the output image.
- Parameters
-
[in] | context | The reference to the overall context. |
[in] | input | The input image. |
[out] | output | The output image. |
[in] | policy | A vx_convert_policy_e enumeration. |
[in] | shift | The shift value. |
- Returns
- A
vx_status_e
enumeration.
- Return values
-
VX_SUCCESS | Success |
* | An error occurred. See vx_status_e .. |