Convolution Integral for two dimensional data. More...

Functions

AFAPI array convolve2 (const array &signal, const array &filter, const convMode mode=AF_CONV_DEFAULT, const convDomain domain=AF_CONV_AUTO)
 C++ Interface for convolution on two dimensional data. More...
 
AFAPI af_err af_convolve2 (af_array *out, const af_array signal, const af_array filter, const af_conv_mode mode, af_conv_domain domain)
 C Interface for convolution on two dimensional data. More...
 

Detailed Description

Convolution Integral for two dimensional data.

A convolution is a common operation between a source array, a, and a filter (or kernel) array b. The answer to the convolution is the same as computing the coefficients in polynomial multiplication, if a and b are the coefficients.

Another way to think about it is that the filter kernel is centered on each pixel in a, and the output for that pixel or data point is the sum of the products.

Depending on the dimensions of the input signal and the filter signal, any one of the following batch mode convolutions take place.

For example, if the signal is two dimensional with m & n as sizes along the 0th & 1st dimensions respectively, then the possible batch operations are as follows.

Input Signal Dimensions Filter Signal Dimensions Batch Mode Explanation
[m n 1 1] [m n 1 1] One to One Output will be a single convolve array
[m n 1 1] [m n p 1] One to Many Output will be 3d array with 2nd dimension length as p - p filters applied to same input
[m n p 1] [m n 1 1] Many to One Output will be 3d array with 2nd dimension length as p - 1 filter applied to p inputs
[m n p 1] [m n p 1] Many to ManyOutput will be 3d array with 2nd dimension length as p - p filter applied to p inputs in one-to-one correspondence

Function Documentation

AFAPI af_err af_convolve2 ( af_array out,
const af_array  signal,
const af_array  filter,
const af_conv_mode  mode,
af_conv_domain  domain 
)

C Interface for convolution on two dimensional data.

Parameters
[out]outis convolved array
[in]signalis the input signal
[in]filteris the signal that shall be flipped for the convolution operation
[in]modeindicates if the convolution should be expanded or not(where output size equals input)
[in]domainspecifies if the convolution should be performed in frequency os spatial domain
Returns
AF_SUCCESS if the convolution is successful, otherwise an appropriate error code is returned.
Note
The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.
AFAPI array af::convolve2 ( const array signal,
const array filter,
const convMode  mode = AF_CONV_DEFAULT,
const convDomain  domain = AF_CONV_AUTO 
)

C++ Interface for convolution on two dimensional data.

//vector<dim4> numDims;
//vector<vector<float> > in;
af::array signal(numDims[0], &(in[0].front()));
//signal dims = [15 17 1 1]
af::array filter(numDims[1], &(in[1].front()));
//filter dims = [5 5 2 1]
//output dims = [15 17 1 1] - same as input since expand(3rd argument is false)
//however, notice that the 3rd dimension of filter is > 1.
//So, one to many batch mode will be activated automatically
//where the 2d input signal is convolved with each 2d filter
//and the result will written corresponding slice in the output 3d array
Parameters
[in]signalis the input signal
[in]filteris the signal that shall be flipped for the convolution operation
[in]modeindicates if the convolution should be expanded or not(where output size equals input)
[in]domainspecifies if the convolution should be performed in frequency os spatial domain
Returns
the convolved array
Note
The default parameter of domain, AF_CONV_AUTO, heuristically switches between frequency and spatial domain.