Edge detection (also called “boundary detection”) is a fundamental problem in image processing. The ability to accurately detect visible “edges” in an image is what makes possible everything from OCR to silly Instagram effects. In this project, I’ve implemented six well-known edge detection algorithms.

For those who have never used edge detection algorithms before, here are examples of various outputs:

Original image:

Lost_TV

Prewitt method (horizontal):

lost_1

Prewitt method (vertical):

lost_2

Sobel method (horizontal):

lost_3

Sobel method (vertical):

lost_4

Laplacian method:

lost_5

Hilite method:

lost_6

As an additional reference, I’ve supplied two more edge detection filters using arbitrary convolution matrices. I include these to show that there’s nothing “magical” about edge detection - and in fact, depending on the purpose of your edge-detector, it may actually be worthwhile to use a custom approach instead of a well-known one.

Custom method 1:

lost_7

Custom method 2:

lost_8

Download the sample app and source code from GitHub

For a more advanced exploration of image edge-detection, you might check out the source code for the Effects > Edge menu of my open-source photo editor, PhotoDemon. It provides even more edge detectors, including variable shape and radii filters like a Range filter:

PD_range_filter_screenshot.png