Convolution filters
AForge.NET framework provides convolution filter and a set of derived filters, which allow
to perform image convolution with common kernels.
Below is the list of implemented convolution filters and the result of their application to the below source
image.
Source image
Convolution
The filter implements convolution operator, which calculates each pixel of the result image as weighted sum of the
correspond pixel and its neighbors in the source image.
// define emboss kernel
int[,] kernel = {
{ -2, -1, 0 },
{ -1, 1, 1 },
{ 0, 1, 2 } };
// create filter
Convolution filter = new Convolution( );
// apply the filter
filter.ApplyInPlace( image );

(Note: The image was grayscaled before applying convolution)
Blur
The filter performs convolution filter using a blur kernel.
Sharpen
The filter performs convolution filter using a sharpen kernel.
Edges
The filter performs convolution filter using a edges kernel.
Gaussian Blur
The filter performs convolution filter using a blur kernel, which is calculate with the help of
Kernel2D(Int32) method.
// create filter with kernel size equal to 11
// and Gaussia sigma value equal to 4.0
GaussianBlur filter = new GaussianBlur( 4, 11 );
// apply the filter
filter.ApplyInPlace( image );
Gaussian Sharpen
The filter performs convolution filter using a sharpen kernel, which is calculate with the help of
Kernel2D(Int32) method.
// create filter with kernel size equal to 11
// and Gaussia sigma value equal to 4.0
GaussianSharpen filter = new GaussianSharpen( 4, 11 );
// apply the filter
filter.ApplyInPlace( image );
|