Friday, January 31, 2014

Line Detector in C # ( C sharp )

This is my post related with C # (C sharp). In this post, I will explain the steps of making the application of C #. Tutorial-making an application Line Detector is part of the C # application usage as it relates to the process image. Processed images will look for existing lines in the picture. Now it's time to direct the implementation of the program.
Maybe many of you already know very well about the programming language one, namely how to find lines on the picture of any type by using the C # programming language. In my implementation using stiap Microsoft Visual Studio 2012.
Please read :
1. the first step, open the C # program and create a new file by choosing File > > New Project (Ctrl + Shift + N) > > select Windows Application, and name the file as per your liking (for example LineDetector) and press OK. Next would come an empty form.

2. a Component used for this simple program is:
   • OpenFileDialog
   • PictureBox
   • Button
Click and put option component of the program which will be used as the image below :


3. Then double click on the button "Load" and add the following code :


OpenFileDialog file = new OpenFileDialog();
string lokasi = file.InitialDirectory;
lokasi = @"C:\Users\ardha\Desktop";
file.Title = "Open Image File";
file.Filter = "Image Files(*.jpg,*.png,*.tiff,*.bmp,*.gif)|*.jpg;*.png;*.tiff;*.bmp;*.gif";
file.FilterIndex = 2;
file.RestoreDirectory = true;
if (file.ShowDialog() == DialogResult.OK)
                     {
                     pictureBox1.Image = new Bitmap(file.FileName);
                                     }

The purpose of the button loads the image file is to choose what you'd like displayed in the picture box. The desired file types can be specified via the syntax Filter (in the above example file.Filter), whereas if you want to directly refer to a particular directory can be used syntax InitialDirectory (in the above example file.InitialDirectory)

4. whereas, to change the image file onto keabuan, double click on the button "Convert" and add the following code :


            Line = new Bitmap(pictureBox1.Image);
            pictureBox1.Image = LineDetector (Line);

Here we need a declaration to "LineDetector", the code LineDetector as follows:


            CannyEdgeDetector cany = new CannyEdgeDetector(0, 70);
            Bitmap final = cany.Apply(gambar);

            return final;

the final return;

5. in the writing of the code is dibutuhlan. dll from AForge. dll can be downloaded here.
Add the following code:

using AForge.Imaging.Filters;

6. the application is complete, after adding the source code above, lives in the run course. And the results were as follows:


For more details on this please downlaod program understanding program files and full-length project
download program files binary here
download full project here
download the exe only here
download the document here
download picture here
download reeference here 
for more information contact on ardhamail@gmail.com

Guide to download: click the download link provided above, a page will appear after that adf.ly, wait a few seconds until appears on the top right corner of the ad skip writing. Click the button, the page will appear after that ziddu, please click on the download button that appears on the page ziddu
NB: in this tutorial programs are written using the Visual studio IDE. with the target framework > 4.0. So at a minimum your computer must be installed or windows vista or windows xp with the .NET framework 4.0 to be able to run programs *. exe, while for open projectnya inevitably must install microsoft visual studio 2012

0 comments:

Post a Comment