C# Image Processing with AForge.NET Framework
A couple of days ago i found a great framework called AForge.NET.
AForge.NET is a C# framework designed for developers and researchers in the fields of Computer Vision and Artificial Intelligence – image processing, neural networks, genetic algorithms, machine learning, robotics, etc.
The framework is published under LGPL v3 license and comprised by the set of libraries and sample applications, which demonstrate their features:
- AForge.Imaging – library with image processing routines and filters
- AForge.Vision – computer vision library
- AForge.Neuro – neural networks computation library
- AForge.Genetic – evolution programming library
- AForge.MachineLearning – machine learning library
- AForge.Robotics – library providing support of some robotics kits
- AForge.Video – set of libraries for video processing
The framework is provided not only with different libraries and their sources, but with many sample applications, which demonstrate the use of this framework, and with documentation help files, which are provided in HTML Help format.
As you can see this framework contains varied libraries, but as for me i was especially interested in the image processing routines and filters.
Let’s see the CannyEdgeDetector in action.
using AForge.Imaging.Filters;
// Loading some file
using (Bitmap SampleImage = (Bitmap)Image.FromFile("test.jpg"))
{
// We must convert it to grayscale because
// the filter accepts 8 bpp grayscale images
Grayscale GF = new Grayscale(0.2125, 0.7154, 0.0721);
using (Bitmap GSampleImage = GF.Apply(SampleImage))
{
// Saving the grayscale image, so we could see it later
GSampleImage.SaveAsJpeg("testBW.jpg", 100);
// Detecting image edges and saving the result
CannyEdgeDetector CED = new CannyEdgeDetector(0,70);
CED.ApplyInPlace(GSampleImage);
GSampleImage.SaveAsJpeg("testEDGED.jpg",100);
}
}
// SaveAsJpeg is an extension method i wrote to be able to save
// Jpeg images with parametrized quality
// You can use Image.Save ("image.jpg", ImageFormat.Jpeg) instead
Now, let see the results ( click the image to see full size )
- The original image
- Grayscaled image
- Edged image
The result is great, and of course we can modify the threshold levels to gain even better results.
As for other filter and effects there are many of them in this library.
There are Noise generators, color correction filters, smoothing filters and more.
Sure, it’s no Photoshop, but i must say it’s very close to it.
Hope you will find this useful, I did.
A few posts you might find interesting:

![The original image [ AForge Test ] The original image](http://kossovsky.net/wp-content/uploads/2009/07/AForgeSamples-150x150.jpg)
![Grayscaled image [ AForge Test ] Grayscaled image](http://kossovsky.net/wp-content/uploads/2009/07/AForgeSamplesGrayscale-150x150.jpg)
![Edged image [ AForge Test ] Edged image](http://kossovsky.net/wp-content/uploads/2009/07/AForgeSamplesResult-150x150.jpg)
I installed the latest version of Aforg.net (2.0 beta). Although there is an option to do full installation (including source code) but i tried several times but no source codes was included. I went to one of the link provided by the author and I could manege to download very old version of source code. can someone help me how I can have access to latest version of source code.
@Jimmi
You can download the lastest version at http://code.google.com/p/aforge/downloads/list
After installing it (Full mode) you can find the source code in the following directory : C:\Program Files\AForge.NET\Sources\
@Xander
Many thanks for your reply. This time I did install it on another computer and be able to have access to source code.Thanks.