O'Reilly logo

NumPy Cookbook - Second Edition by Ivan Idris

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Detecting edges

Edge detection is another popular image processing technique (http://en.wikipedia.org/wiki/Edge_detection). scikit-image has a Canny filter implementation based on the standard deviation of the Gaussian distribution, which can perform edge detection out of the box. Besides the image data as a 2D array, this filter accepts the following parameters:

  • Standard deviation of the Gaussian distribution
  • Lower bound threshold
  • Upper bound threshold

How to do it...

We will use the same image as in the previous recipe. The code is almost the same (see edge_detection.py). Pay extra attention to the line where we call the Canny filter function:

from sklearn.datasets import load_sample_images import matplotlib.pyplot as plt import skimage.feature dataset ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required