Basic Image Edge Detection
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:
Prewitt method (horizontal):
Prewitt method (vertical):
Sobel method (horizontal):
Sobel method (vertical):
Laplacian method:
Hilite method:
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:
Custom method 2:
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: