Do more. Code less. Free software for GPU computing.
<scroll to top>
Enumerations | Functions

Filtering and Convolution (1D,2D,3D,separable)

Image and Signal Processing

Enumerations

enum  afConv { afConvSame = 0, afConvValid = -1, afConvFull = 1 }
 

Specify which part of convolution to retain.

More...

Functions

array filter (const array &image, const array &kernel)
 Image Filter.
array medfilt (const array &image, const unsigned height=3, const unsigned width=3)
 Median filtering within window (default 3x3)
array convolve (const array &f1, const array &f2, const array &signal, afConv shape=afConvFull)
 Separable convolution (2D) with device arrays.
template<typename ty >
array convolve (unsigned n1, const ty *f1, unsigned n2, const ty *f2, const array &signal, afConv shape=afConvFull)
 Separable convolution (2D) with host arrays.
array convolve (const array &signal, const array &filter, afConv shape=afConvFull)
 Convolution (1D,2D,3D).
template<typename ty >
array convolve (const array &signal, unsigned ndims, unsigned *dims, const ty *h_kernel, afConv shape=afConvFull)
 Convolution (1D,2D,3D) with host filter.

Enumeration Type Documentation

enum afConv

Specify which part of convolution to retain.

   array x3 = randu(1,3), x5 = randu(1,5);
   print(convolve(x3, x5, afConvSame));  // 1x3 output
   print(convolve(x5, x3, afConvSame));  // 1x5 output
   print(convolve(x3, x5, afConvFull));  // 1x7 output
   print(convolve(x5, x3, afConvValid)); // 1x3 output
   print(convolve(x3, x5, afConvValid)); // empty output since filter bigger than signal
Enumerator:
afConvSame 

the central part of the convolution that is the same size as signal (default)

afConvValid 

the parts of the convolution that are computed without zero-padded edges

afConvFull 

the full convolution


Function Documentation

array af::filter ( const array &  image,
const array &  kernel 
)

Image Filter.

Parameters:
[in]image
[in]kernelcoefficient matrix
Returns:
filtered image of same size as input
Note:
Output is same size as input. Filtering done using correlation. Array values outside bounds are assumed to have zero value (0).
Examples:
examples/image/gfor_hist_demo.cpp, and examples/image/image_demo.cpp.
array af::medfilt ( const array &  image,
const unsigned  height = 3,
const unsigned  width = 3 
)

Median filtering within window (default 3x3)

Parameters:
[in]image
[in]heightof window (default 3)
[in]widthof window (default 3)
array af::convolve ( const array &  f1,
const array &  f2,
const array &  signal,
afConv  shape = afConvFull 
)

Separable convolution (2D) with device arrays.

Parameters:
[in]f1filter along the columns (first dimension)
[in]f2filter along the rows (second dimension)
[in]signal
[in]shapetype of convolution (default: afConvFull)
Examples:
examples/misc/convolve.cpp, examples/optical_flow/optical_flow.cpp, and examples/swe/swe.cpp.
array af::convolve ( unsigned  n1,
const ty *  f1,
unsigned  n2,
const ty *  f2,
const array &  signal,
afConv  shape = afConvFull 
)

Separable convolution (2D) with host arrays.

Parameters:
[in]n1number of elements in f1
[in]f1host pointer containing the column filter
[in]n2number of elements in f2
[in]f2host pointer containing the row filter
[in]signal
[in]shapetype of convolution (default: afConvFull)
array af::convolve ( const array &  signal,
const array &  filter,
afConv  shape = afConvFull 
)

Convolution (1D,2D,3D).

Parameters:
[in]signal
[in]filter
[in]shapetype of convolution (default: afConvFull)
array af::convolve ( const array &  signal,
unsigned  ndims,
unsigned *  dims,
const ty *  h_kernel,
afConv  shape = afConvFull 
)

Convolution (1D,2D,3D) with host filter.

Parameters:
[in]signal
[in]ndimsNumber of dimensions for the filter h_kernel
[in]dimsArray containing dimension sizes of filter h_kernel
[in]h_kernelHost-side array containing the filter kernel coefficients
[in]shapetype of convolution (default: afConvFull)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines