Click or drag to resize
Accord.NET (logo)

Convolution Class

Convolution filter.
Inheritance Hierarchy
SystemObject
  Accord.Imaging.FiltersBaseUsingCopyPartialFilter
    Accord.Imaging.FiltersConvolution
      More...

Namespace:  Accord.Imaging.Filters
Assembly:  Accord.Imaging (in Accord.Imaging.dll) Version: 3.8.0
Syntax
public class Convolution : BaseUsingCopyPartialFilter
Request Example View Source

The Convolution type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyDivisor
Division factor.
Public propertyDynamicDivisorForEdges
Use dynamic divisor for edges or not.
Public propertyFormatTranslations
Format translations dictionary.
(Overrides BaseUsingCopyPartialFilterFormatTranslations.)
Public propertyKernel
Convolution kernel.
Public propertyProcessAlpha
Specifies if alpha channel must be processed or just copied.
Public propertyThreshold
Threshold to add to weighted sum.
Top
Methods
  NameDescription
Public methodApply(Bitmap)
Apply filter to an image.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApply(BitmapData)
Apply filter to an image.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApply(UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApply(UnmanagedImage, UnmanagedImage)
Apply filter to an image in unmanaged memory.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(Bitmap)
Apply filter to an image.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(BitmapData)
Apply filter to an image.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(UnmanagedImage)
Apply filter to an unmanaged image.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(Bitmap, Rectangle)
Apply filter to an image or its part.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(BitmapData, Rectangle)
Apply filter to an image or its part.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodApplyInPlace(UnmanagedImage, Rectangle)
Apply filter to an unmanaged image or its part.
(Inherited from BaseUsingCopyPartialFilter.)
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodProcessFilter
Process the filter on the specified image.
(Overrides BaseUsingCopyPartialFilterProcessFilter(UnmanagedImage, UnmanagedImage, Rectangle).)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

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. The weights are set by convolution kernel. The weighted sum is divided by Divisor before putting it into result image and also may be thresholded using Threshold value.

Convolution is a simple mathematical operation which is fundamental to many common image processing filters. Depending on the type of provided kernel, the filter may produce different results, like blur image, sharpen it, find edges, etc.

The filter accepts 8 and 16 bpp grayscale images and 24, 32, 48 and 64 bpp color images for processing. Note: depending on the value of ProcessAlpha property, the alpha channel is either copied as is or processed with the kernel.

Sample usage:

// define emboss kernel
int[,] kernel = {
            { -2, -1,  0 },
            { -1,  1,  1 },
            {  0,  1,  2 } };
// create filter
Convolution filter = new Convolution( kernel );
// apply the filter
filter.ApplyInPlace( image );

Initial image:

Result image:

See Also
Inheritance Hierarchy