Canny edge detector.

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


public class CannyEdgeDetector : BaseUsingCopyPartialFilter


The filter searches for objects' edges by applying Canny edge detector. The implementation follows Bill Green's Canny edge detection tutorial.

Note:The implemented canny edge detector has one difference with the above linked algorithm. The difference is in hysteresis step, which is a bit simplified (getting faster as a result). On the hysteresis step each pixel is compared with two threshold values: HighThreshold and LowThreshold. If pixel's value is greater or equal to HighThreshold, then it is kept as edge pixel. If pixel's value is greater or equal to LowThreshold, then it is kept as edge pixel only if there is at least one neighbouring pixel (8 neighbours are checked) which has value greater or equal to HighThreshold; otherwise it is none edge pixel. In the case if pixel's value is less than LowThreshold, then it is marked as none edge immediately.

The filter accepts 8 bpp grayscale images for processing.

Sample usage:

// create filter
CannyEdgeDetector filter = new CannyEdgeDetector( );
// apply the filter
filter.ApplyInPlace( image );

Initial image:

Result image:

Inheritance Hierarchy


See Also