Sobel edge detector.

Namespace:  AForge.Imaging.Filters
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public class SobelEdgeDetector : BaseUsingCopyPartialFilter

Remarks

The filter searches for objects' edges by applying Sobel operator.

Each pixel of the result image is calculated as approximated absolute gradient magnitude for corresponding pixel of the source image:

Copy 
|G| = |Gx| + |Gy] ,
where Gx and Gy are calculate utilizing Sobel convolution kernels:
Copy 
   Gx         Gy
-1 0 +1    +1 +2 +1
-2 0 +2     0  0  0
-1 0 +1    -1 -2 -1
Using the above kernel the approximated magnitude for pixel x is calculate using the next equation:
Copy 
P1 P2 P3
P8  x P4
P7 P6 P5

|G| = |P1 + 2P2 + P3 - P7 - 2P6 - P5| +
      |P3 + 2P4 + P5 - P1 - 2P8 - P7|

The filter accepts 8 bpp grayscale images for processing.

Sample usage:

CopyC#
// create filter
SobelEdgeDetector filter = new SobelEdgeDetector( );
// apply the filter
filter.ApplyInPlace( image );

Initial image:

Result image:

Inheritance Hierarchy

System..::.Object
  AForge.Imaging.Filters..::.BaseUsingCopyPartialFilter
    AForge.Imaging.Filters..::.SobelEdgeDetector

See Also