 A high-performance general-purpose compute library
convolve (Separable)

Separable Convolution. More...

## Functions

AFAPI array convolve (const array &col_filter, const array &row_filter, const array &signal, const convMode mode=AF_CONV_DEFAULT)
C++ Interface for separable convolution on two dimensional signals.

AFAPI af_err af_convolve2_sep (af_array *out, const af_array col_filter, const af_array row_filter, const af_array signal, const af_conv_mode mode)
C Interface for separable convolution on two dimensional signals.

## Detailed Description

Separable Convolution.

Separable Convolution is faster equivalent of the canonical 2D convolution with an additional prerequisite that the filter/kernel can be decomposed into two separate spatial vectors. A classic example of such separable kernels is sobel operator. Given below is decomposition of vertical gradient of sobel operator.

$$\begin{bmatrix} -1 & 0 & +1 \\ -2 & 0 & +2 \\ -1 & 0 & +1 \\ \end{bmatrix}$$

can be decomposed into two vectors shown below.

$$\begin{bmatrix} 1 \\ 2 \\ 1 \\ \end{bmatrix}$$

$$\begin{bmatrix} -1 & 0 & +1 \\ \end{bmatrix}$$

## ◆ af_convolve2_sep()

 AFAPI af_err af_convolve2_sep ( af_array * out, const af_array col_filter, const af_array row_filter, const af_array signal, const af_conv_mode mode )

C Interface for separable convolution on two dimensional signals.

Parameters
 [out] out is convolved array [in] col_filter is filter that has to be applied along the coloumns [in] row_filter is filter that has to be applied along the rows [in] signal is the input array [in] mode indicates if the convolution should be expanded or not(where output size equals input)
Returns
AF_SUCCESS if the convolution is successful, otherwise an appropriate error code is returned.
Note
Separable convolution only supports two(ONE-to-ONE and MANY-to-ONE) batch modes from the ones described in the detailed description section.

## ◆ convolve()

 AFAPI array convolve ( const array & col_filter, const array & row_filter, const array & signal, const convMode mode = AF_CONV_DEFAULT )

C++ Interface for separable convolution on two dimensional signals.

// vector<dim4> numDims;
// vector<vector<float> > in;
array signal(numDims, &(in.front()));
// signal dims = [3 4 2 1]
array cFilter(numDims, &(in.front()));
// coloumn filter dims = [2 1 1 1]
array rFilter(numDims, &(in.front()));
// row filter dims = [3 1 1 1]
array output = convolve(cFilter, rFilter, signal, AF_CONV_DEFAULT);
// output signal dims = [3 4 2 1] - same as input since 'expand = false'
// notice that the input signal is 3d array, therefore
// batch mode will be automatically activated.
// output will be 3d array with result of each 2d array convolution(with
// same filter) stacked along the 3rd dimension
A multi dimensional data container.
Definition: array.h:37
@ AF_CONV_DEFAULT
Output of the convolution is the same size as input.
Definition: defines.h:305
AFAPI array convolve(const array &signal, const array &filter, const convMode mode=AF_CONV_DEFAULT, const convDomain domain=AF_CONV_AUTO)
C++ Interface for convolution any(one through three) dimensional signals.
Parameters
 [in] signal is the input signal [in] col_filter is the signal that shall be along coloumns [in] row_filter is the signal that shall be along rows [in] mode indicates if the convolution should be expanded or not(where output size equals input)
Returns
the convolved array
Note
The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
Separable convolution only supports two(ONE-to-ONE and MANY-to-ONE) batch modes from the ones described in the detailed description section.