Search This Blog

Monday, December 13, 2010

Edge Detection using C# and Aforge.NET

Edge Detection using C# and Aforge.NET


As I have told earlier, I am a newbie to image processing. I am posting things as I work on them. For the past few months I have been  busy with my PhD qualifiers.

Our topic for today is Edge Detection.

Edge Detection:

First step in our segmentation is edge detection. I will take a simple example to do this. Here is the picture where I am going to do the processing. Actually it is not an image. It is a video stream.

Now I am going to do edge detection in it using Aforge. Before doing edge detection you should first convert into grayscale. There are mutliple ways to do edge detection [ Ref:]. Given below is the code snippet.

image                image

Bitmap image = (Bitmap)eventArgs.Frame.Clone();
Bitmap gsImage = Grayscale.CommonAlgorithms.BT709.Apply(image);
CannyEdgeDetector filter = new CannyEdgeDetector();
Bitmap edge = filter.Apply(gsImage);
pictureBox1.Image = (Bitmap)edge;


Actually I started this topic for image segmentation, but ended up as a Edge detection. I will come up with more topics. Also don’t forget to try other edge detection techniques given in Aforge.NET (link given below).


  1. hi. this seems realy interesting. I've already installed the AForge framework but it seems that it wont work. Is possible to see more of your snipped?
    Many Thanks & CheerzZ

  2. Hi can you please post tutorials of displacement filter and edge detection filters using matrices??