The OpenVX Specification  a73e458
Custom Convolution

Detailed Description

Convolves the input with the client supplied convolution matrix [R00047].

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 [R00048]. If values would have been out of range of U8 for VX_DF_IMAGE_U8, the values are clamped to 0 or 255 [R00049].

\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}

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 [R00050]:

\[ 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 [R00051]

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

The overflow policy used is VX_CONVERT_POLICY_SATURATE [R00052].


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

Function Documentation

◆ vxConvolveNode()

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

[Graph] Creates a custom convolution node.

[in]graphThe reference to the graph [R00247].
[in]inputThe input image in VX_DF_IMAGE_U8 format [R00248].
[in]convThe vx_int16 convolution matrix [R00249].
[out]outputThe output image in VX_DF_IMAGE_U8 or VX_DF_IMAGE_S16 format [R00250].
vx_node [R00251].
Return values
vx_nodeA node reference. Any possible errors preventing a successful creation should be checked using vxGetStatus