The OpenVX Specification  r28647
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Custom Convolution

Detailed Description

Convolves the input with the client supplied convolution matrix.

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 = 9;
vx_convolution scharr_x = vxCreateConvolution(context, 3, 3);
vxSetConvolutionAttribute(scharr_x, VX_CONVOLUTION_ATTRIBUTE_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 vxConvolveNode (vx_graph graph, vx_image input, vx_convolution conv, vx_image output)
 [Graph] Creates a custom convolution node. More...
 
vx_status vxuConvolve (vx_context context, vx_image input, vx_convolution matrix, vx_image output)
 [Immediate] Computes a convolution on the input image with the supplied matrix. More...
 

Function Documentation

vx_node 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_S16 format.
Returns
vx_node.
Return values
0Node could not be created.
*Node handle.
vx_status vxuConvolve ( vx_context  context,
vx_image  input,
vx_convolution  matrix,
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]matrixThe convolution matrix.
[out]outputThe output image in VX_DF_IMAGE_S16 format.
Returns
A vx_status_e enumeration.
Return values
VX_SUCCESSSuccess
*An error occurred. See vx_status_e.