intelliproject logo

Location: Computer science - Image processing    License: The Intelliproject Open License (IPOL)

Image processing – Edge Detection filters with c++ and GDI+

Posted by Silviu Caragea

This article explains 2 different ways to do edge detection: first method is based on: Sobel , Prewitt and Kirsh and the second one is based on the difference between pairs of pixel around the current pixel.

Skill: Advanced

Posted: 06/11/2008

Views: 7778

Rating: 4.56 /5

Popularity: 4.35

Sign Up to vote for this article

Introduction

Edge detection is a fundamental tool used in most image processing applications to obtain information from the frames as a precursor step to feature extraction and object segmentation. This process detects outlines of an object and boundaries between objects and the background in the image. An edge-detection filter can also be used to improve the appearance of blurred or anti-aliased video streams.

In this article I will show 2 different ways to do edge detection. First method is based on convolution filters operators like: Sobel , Prewitt and Kirsh. The second one is based on the difference between pairs of pixel around the current pixel.

app.jpg

Convolution Filters - Sobel, Prewitt and Kirsh

The convolution filters are described in one of my preview articles which can be found here.

In this approach, three different masks are used to detect edges named after their inventors, Sobel, Prewitt, and Kirsh. In each case, a horizontal version of the filter is applied to one bitmap, vertical version to another, and one of these two images is used to merge both horizontal and vertical version together using the following formula:

pixel = sqrt(pixel1 *pixel1 + pixel2 * pixel2)

operators.jpg

Source code for Sobel, Prewitt and Kirsh edge detection filters

The above function can be found in CEdgeDetectionFilters.cpp .

Difference Edge Detection

The difference edge detection detects the difference between pairs of pixel around the current processed pixel. It used the highest value from the difference of the four pairs of pixels that can be used to form a line through the middle pixel.

Update history

19/05/2009 Compatible with Visual Studio 2008
Sobel mask bug fixed

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Silviu Caragea

Silviu Caragea is the Founder, Administrator and Chief Editor who wrote and runs The IntelliProject.

He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy.

His programming experience includes:
- C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL)
- Open Source libraries :CURL & Boost
- HTML, CSS
- Java (SE,ME)
- JavaScript, Ajax, Google Web Toolkit (GWT)
- Php, MySQL
-Oracle, PL SQL
- C# .NET
-Objective C, IPhone SDK, Cocoa

Location: Romania
Ocupation: Software Engineer
Home page: http://www.intelliproject.net

Posted by skaer at 11/12/2009 21:52
hi, any chance to have it in C#?

Sign up to post message on the article message board!