CSFG
English Deutsch Beta Español Beta język polski (2.6.0)
Chapters Curriculum Guides Appendices

Computer Vision
14.6. Edge detection

Computer Vision

  • 14.1. What's the big picture?
  • 14.2. Lights, camera, action!
  • 14.3. Noise
  • 14.4. Thresholding
  • 14.5. Face recognition
  • 14.6. Edge detection
    • Activity: Edge detection evaluation
  • 14.7. Depth
  • 14.8. The whole story!
  • 14.9. Further reading

A useful technique in computer vision is edge detection, where the boundaries between objects are automatically identified. Having these boundaries makes it easy to segment the image (break it up into separate objects or areas), which can then be recognised separately.

For example, here's a photo where you might want to recognise individual objects:

Image of a fruit bowl

And here's a version that has been processed by an edge detection algorithm:

The image above with canny edge detection applied

Notice that the grain on the table above has affected the quality; some pre-processing to filter that would have helped!

Earlier, we looked at how we could use a convolutional kernel to blur an image. One of the common techniques in edge detection also requires a convolutional kernel. If we multiply the values of pixels on one side of each point on the image by a negative amount, and pixels on the other side by a positive amount, then combine the results, we'll discover a number which represents the difference between pixels on the two sides. This technique is called finding the image gradient. The following interactive allows you to do that, then apply a threshold to the result so that you can begin to spot likely edges in a picture.

Thumbnail of Pixel Viewer interactive

Edge Detection

There are a few commonly used convolutional kernels that people have come up with for finding edges. After you've had a go at coming up with some of your own, have a look at the Prewitt operator, the Roberts cross and Sobel operator on wikipedia. Try these out in the interactive. What results do you get from each of these?

There are a number of good edge detections out there, but one of the more famous ones is the Canny edge detection algorithm. This is a widely used algorithm in computer vision, developed in 1986 by John F. Canny. You can read more about Canny edge detection on Wikipedia.

You could extend the techniques used in the above interactive by adding a few more processing stages. If you were to apply a gaussian filter to the image first, then do some work to favour edges that were connected to other edges, then you would be on your way to implementing the Canny edge detector.

14.6.1.

Activity: Edge detection evaluation

With the edge detection interactive above, try uploading different images and determining how good different convolutional kernels are at detecting boundaries in the image. Capture images to put in your report as examples to illustrate your experiments with the detector.

  • Can the detector find all edges in the image? If there are some missing, why might this be?
  • Are there any false edge detections? Why did they system think that they were edges?
  • Does the lighting on the scene affect the quality of edge detection?
  • Does the system find the boundary between two colours? How similar can the colours be and still have the edge detected?
  • How fast can the system process the input? Does this change with more complex kernels?
  • How well does the system deal with an image with text on it?
Previous:
Face recognition
Next:
Depth

Looking for something for primary schools? Check out CS Unplugged.

The Computer Science Field Guide is an online interactive resource for high school students learning about computer science.

Useful Links

  • About
  • Chapters
  • Interactives
  • Curriculum Guides

Community

  • Twitter
  • YouTube
  • GitHub

Help

  • Search
  • Glossary
  • Feedback

Switch to teacher mode

English | Deutsch | Español | język polski (2.6.0)

The Computer Science Field Guide material is open source on GitHub, and this website's content is shared under a Creative Commons Attribution-ShareAlike 4.0 International license. The Computer Science Field Guide is a project by the Computer Science Education Research Group at the University of Canterbury, New Zealand. Icons provided generously by icons8.

3.12.6

This definition is not available in English, sorry!