1      Introduction

Today we are looking at graphic functions today we are looking at Susan Corner Detection.

2      Building the Sample

The sample is built in Visual Studio 2012 Ultimate as an x86 targeted application using .Net Framework 4. We will be using NuGet packages, a number of 3rd party libraries. All of which will be fully explained to you ensuring that the final compilation of your application will be hassle free. Oh! And the sample code is verbosely commented so you should have no problem in working out what the code does.

3      Let’s Get Started!

The class implements Susan corners detector, which is described by S.M. Smith in: S.M. Smith, "SUSAN - a new approach to low level image processing", Internal Technical Report TR95SMS1, Defense Research Agency, Chobham Lane, Chertsey, Surrey, UK, 1995.

Some implementation notes:

Analyzing each pixel and searching for its USAN area, the 7x7 mask is used, which is comprised of 37 pixels. The mask has circle shape:

           xxx

     xxxxx

    xxxxxxx

    xxxxxxx

    xxxxxxx

     xxxxx

      xxx

 

·         In the case if USAN's center of mass has the same coordinates as nucleus (central point), the pixel is not a corner.

·         For noise suppression the 5x5 square window is used.

The class processes only grayscale 8 bpp and color 24/32 bpp images. In the case of color image, it is converted to grayscale internally using GrayscaleBT709 filter.

Open Visual Studio 2012 and select your previous created windows forms application. I will be commenting in this sample using C# but a VB.NET version of the code is available for downloading as well!

Corner Detection requires corners, if your image is complicated it will see corners everywhere – so this is really better for simple images but you can use it on an Image you want.

We have created a “Susan Corner Detection Settings” user control to allow the end user select the properties they want the Susan Corner Detection to run with. Right Clicking on the Image itself will allow you to reset the image to it’s original un-modified self.

We have used the third party, and excellent, open source Aforge Imaging library which handles the actual corner detection work for us. We install this into our application by right clicking on our Solution in the Solutiuon Explorer and selecting Manage NuGet Packages for solution… Search for AForge and install the Aforge.Imaging and Aforge.Controls libraries.

This means our Susan class looks like this:

C#
Edit|Remove
class Susan 
       { 
              private string CurrentImage; 
              private FrmProcessing processing; 
 
              public delegate void ImageCompleteHandler(List<IntPoint> Corners); 
              public event ImageCompleteHandler ImageComplete; 
 
  
              public Susan(string CurrentImage) 
              { 
                     this.CurrentImage = CurrentImage; 
              } 
 
              public void GetCorners(int diff, int geo) 
              { 
                     // create corners detector's instance 
                     SusanCornersDetector scd = new SusanCornersDetector(diff, geo); 
                     // process image searching for corners 
                     List<IntPoint> corners = scd.ProcessImage(AForge.Imaging.Image.FromFile(this.CurrentImage)); 
                     if (ImageComplete != null) ImageComplete(corners); 
              } 
       } 
 
 

Which raises an ImageComplete event when the processing has … well, completed; at which point we process the coordinates returned by Aforge and draw those coordinates onto the image using this method:

C#
Edit|Remove
private void DrawCorners(List<IntPoint> Corners) 
              { 
                     // Load image and create everything you need for drawing 
                     Bitmap image = new Bitmap(pbImage.Image); 
                     Graphics graphics = Graphics.FromImage(image); 
                     SolidBrush brush = new SolidBrush(Color.Red); 
                     Pen pen = new Pen(brush); 
 
                     // Visualization: Draw 3x3 boxes around the corners 
                     foreach (IntPoint corner in Corners) 
                     { 
                           graphics.DrawRectangle(pen, corner.X - 1, corner.Y - 133); 
                     } 
 
                     // Display 
                     pbImage.Image = image; 
           } 

3.1    Source Code Files

 

 

·          

 

 

·        

3.2    More Information

To convert the solution to a previous version of Visual Studio you can use this free application: http://vsprojectconverter.codeplex.com/ or download and use Visual Studio 2013 Express which is freely available from Microsoft from here: http://www.visualstudio.com/downloads/download-visual-studio-vs.

Cyotek.Windows.Forms.ImageBox.dll (http://cyotek.com/blog/imagebox-update-version-1-1-0-0)

Win8ProgressRing, used in FrmProcessing is available here: http://www.codeproject.com/Articles/648664/Win8ProgressRing-Control

The Visual Basic version of this code was generated by the free tool: Instant VB from http://www.tangiblesoftwaresolutions.com/