The C++ interface for filter. More...

array filter (const array &image, const array &kernel)
 Image Filtering. More...

Detailed Description

The C++ interface for filter.

Apply an arbitrary filter (also known as a kernel) to an image. This function can be used for several tasks in image processing including noise removal or blurring (especially when combined with the gaussiankernel).

This function involves specifying a 1D or 2D filter, a (usually) small array with an odd number of pixels in each dimension. Each pixel in the output image is the weighted sum of the original pixels and all neighboring pixels, where the weight is specified by the filter.

Pixels outside of the image contribute a 0 to the average. This occurs when processing pixels on the edge of an image, or pixels that are close to the edge when a large filter is used.

Function Documentation

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

Image Filtering.

// filter (convolve) an image with a 3x3 sobel kernel
const float h_kernel[] = { -2.0, -1.0, 0.0,
-1.0, 0.0, 1.0,
0.0, 1.0, 2.0 };
array kernel = array(3,3,h_kernel);
array img_out = filter(img_in, kernel);
[in]kernelcoefficient matrix
filtered image (same size as input)
Filtering done using correlation. Array values outside bounds are assumed to have zero value (0).