ImageGear for .NET
Convolve Method
See Also  Example Send Feedback
ImageGear21.Core Assembly > ImageGear.Processing Namespace > ImGearRasterProcessing Class : Convolve Method




page
Image to convolve.
matrix
Two-dimensional convolution matrix.
normalizer
Normalizer (i.e., denominator for every color component value).
resultMode
Mode that defines how the resulting color component value interacts with the source:
  • ImGearConvolutionResults.RAW - the new color component replaces the old one. If the new value is negative then 0 is applied.
  • ImGearConvolutionResults.ABS the new color component replaces the old one. If the new color component is negative then its absolute value is applied.
  • ImGearConvolutionResults.SIGNED - the new color component replaces the old one. If the new color component is negative then it is added to the maximum value of the component range.
  • ImGearConvolutionResults.CENTERED - the new color component is added to the component range center and replaces the old one.
addResultToOriginalPixels
If this flag is true then the calculated values are added to the original ones.
channels
Range of the channels to convolve.

Glossary Item Box

Provides filtering on the base of 2-dimensional convolution matrix.

Syntax

 
Visual Basic
C#
Managed Extensions for C++
C++/CLI
 
 

Parameters

page
Image to convolve.
matrix
Two-dimensional convolution matrix.
normalizer
Normalizer (i.e., denominator for every color component value).
resultMode
Mode that defines how the resulting color component value interacts with the source:
  • ImGearConvolutionResults.RAW - the new color component replaces the old one. If the new value is negative then 0 is applied.
  • ImGearConvolutionResults.ABS the new color component replaces the old one. If the new color component is negative then its absolute value is applied.
  • ImGearConvolutionResults.SIGNED - the new color component replaces the old one. If the new color component is negative then it is added to the maximum value of the component range.
  • ImGearConvolutionResults.CENTERED - the new color component is added to the component range center and replaces the old one.
addResultToOriginalPixels
If this flag is true then the calculated values are added to the original ones.
channels
Range of the channels to convolve.

Remarks

The method processes specified range of channels. It does not provide any special handling for Alpha channel.

Can be applied only to the raster pages with standard (non Run-Ends) DIB.

Example

C#Copy Code
// Convolve an image according to a matrix and normalizer.
// Convolution matrix:
int[,] matrix = new int[,] {
    {-1,1,1},
    {-1,0,1},
    {-1,-1,1}
};
// normalizer to be used as denominator for the matrix.
const double normalizer = 6;
// Channel range to convolve on.
ImGearChannelRange igChannelRange = new ImGearChannelRange(0, igRasterPage.DIB.ChannelCount);
// Apply the convolution, in this case it has an emboss effect.
ImGearRasterProcessing.Convolve(igRasterPage, matrix, normalizer,
    ImGearConvolutionResults.RAW, true, igChannelRange);
Visual BasicCopy Code
' Convolve an image according to a matrix and normalizer.
' Convolution matrix:
Dim matrix As Integer(,) = New Integer(,) { _
 {-1, 1, 1}, _
 {-1, 0, 1}, _
 {-1, -1, 1}}
' normalizer to be used as denominator for the matrix.
Dim normalizer As Double = 6
' Channel range to convolve on.
Dim igChannelRange As New ImGearChannelRange(0, igRasterPage.DIB.ChannelCount)
' Apply the convolution, in this case it has an emboss effect.
ImGearRasterProcessing.Convolve(igRasterPage, matrix, normalizer, _
 ImGearConvolutionResults.RAW, True, igChannelRange)

See Also

©2013. Accusoft Corporation. All Rights Reserved.