The OpenVX Specification  dba1aa3
Custom Convolution

Detailed Description

Convolves the input with the client supplied convolution matrix. The output image dimensions should be the same as the dimensions of the input image.

The client can supply a vx_int16 typed convolution matrix \( C_{m,n} \). Outputs will be in the VX_DF_IMAGE_S16 format unless a VX_DF_IMAGE_U8 image is explicitly provided. If values would have been out of range of U8 for VX_DF_IMAGE_U8, the values are clamped to 0 or 255.

\begin{eqnarray} k_0 &=& \frac{m}{2} \\ l_0 &=& \frac{n}{2} \\ sum &=& \sum_{k=0,l=0}^{k=m-1,l=n-1} input(x+k_0-k, y+l_0-l) C_{k,l} \end{eqnarray}

Note
The above equation for this function is different than an equivalent operation suggested by the OpenCV Filter2D function.

This translates into the C declaration:

// A horizontal Scharr gradient operator with different scale.
vx_int16 gx[3][3] = {
{ 3, 0, -3},
{ 10, 0,-10},
{ 3, 0, -3},
};
vx_uint32 scale = 8;
vx_convolution scharr_x = vxCreateConvolution(context, 3, 3);
vxSetConvolutionAttribute(scharr_x, VX_CONVOLUTION_SCALE, &scale, sizeof(scale));

For VX_DF_IMAGE_U8 output, an additional step is taken:

\[ output(x,y) = \begin{cases} \cr 0 & \text{if } sum < 0 \cr 255 & \text{if } sum / scale > 255 \cr sum / scale & \text{otherwise} \end{cases} \]

For VX_DF_IMAGE_S16 output, the summation is simply set to the output

\[ output(x,y) = sum / scale \]

The overflow policy used is VX_CONVERT_POLICY_SATURATE.

Functions

vx_node VX_API_CALL vxConvolveNode (vx_graph graph, vx_image input, vx_convolution conv, vx_image output)
 [Graph] Creates a custom convolution node. More...
 
vx_status VX_API_CALL vxuConvolve (vx_context context, vx_image input, vx_convolution conv, vx_image output)
 [Immediate] Computes a convolution on the input image with the supplied matrix. More...
 

Function Documentation

vx_node VX_API_CALL vxConvolveNode ( vx_graph  graph,
vx_image  input,
vx_convolution  conv,
vx_image  output 
)

[Graph] Creates a custom convolution node.

Parameters
[in]graphThe reference to the graph.
[in]inputThe input image in VX_DF_IMAGE_U8 format.
[in]convThe vx_int16 convolution matrix.
[out]outputThe output image in VX_DF_IMAGE_U8 or VX_DF_IMAGE_S16 format, which must have the same dimensions as the input image.
Returns
vx_node.
Return values
vx_nodeA node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus
vx_status VX_API_CALL vxuConvolve ( vx_context  context,
vx_image  input,
vx_convolution  conv,
vx_image  output 
)

[Immediate] Computes a convolution on the input image with the supplied matrix.

Parameters
[in]contextThe reference to the overall context.
[in]inputThe input image in VX_DF_IMAGE_U8 format.
[in]convThe vx_int16 convolution matrix.
[out]outputThe output image in VX_DF_IMAGE_U8 or VX_DF_IMAGE_S16 format.
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSSuccess
*An error occurred. See vx_status_e.