Sie sind auf Seite 1von 3

The OpenVX Specication: Custom Convolution https://www.khronos.org/registry/OpenVX/specs...

Custom Convolution
Vision Functions

Detailed Description

Convolves the input with the client supplied convolution matrix.

The client can supply a vx_int16 typed convolution matrix Cm,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.

m
k0 =
2
n
l0 =
2
k=m1,l=n1
sum = input(x + k0 k, y + l0 l)Ck,l
k=0,l=0

Note
The above equation for this function is dierent 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);
vxAccessConvolutionCoefficients(scharr_x, NULL);
vxCommitConvolutionCoefficients(scharr_x, (vx_int16*)gx);
vxSetConvolutionAttribute(scharr_x, VX_CONVOLUTION_ATTRIBUTE_SCALE,
&scale, sizeof(scale));

For VX_DF_IMAGE_U8 output, an additional step is taken:




output(x, y) =
0 ifsum < 0



255 ifsum/scale > 255
sum/scale otherwise
For VX_DF_IMAGE_S16 output, the summation is simply set to the output

output(x, y) = sum/scale

1 of 3 Thursday 13 April 2017 07:28 PM


The OpenVX Specication: Custom Convolution https://www.khronos.org/registry/OpenVX/specs...

The overow 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] graph The reference to the graph.
[in] input The input image in VX_DF_IMAGE_U8 format.
[in] conv The vx_int16 convolution matrix.
[out] output The output image in VX_DF_IMAGE_S16 format.

Returns
vx_node.

Return values
0 Node could not be created.
* Node handle.

2 of 3 Thursday 13 April 2017 07:28 PM


The OpenVX Specication: Custom Convolution https://www.khronos.org/registry/OpenVX/specs...

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] context The reference to the overall context.
[in] input The input image in VX_DF_IMAGE_U8 format.
[in] matrix The convolution matrix.
[out] output The output image in VX_DF_IMAGE_S16 format.

Returns
A vx_status_e enumeration.

Return values
VX_SUCCESS Success
* An error occurred. See vx_status_e.

3 of 3 Thursday 13 April 2017 07:28 PM

Das könnte Ihnen auch gefallen