Get startedGet started for free

Edge detection

In this exercise, you'll detect edges in an image by applying the Sobel filter.

Soap pills of heart and rectangle shapes in blue background
Image preloaded as soaps_image.

Theshow_image() function has been already loaded for you.

Let's see if it spots all the figures in the image.

This exercise is part of the course

Image Processing in Python

View Course

Exercise instructions

  • Import the color module so you can convert the image to grayscale.
  • Import the sobel() function from filters module.
  • Make soaps_image grayscale using the appropriate method from the color module.
  • Apply the sobel edge detection filter on the obtained grayscale image soaps_image_gray.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Import the color module
from ____ import ____

# Import the filters module and sobel function
from skimage.____ import ____

# Make the image grayscale
soaps_image_gray = ____.____(soaps_image)

# Apply edge detection filter
edge_sobel = ____(____)

# Show original and resulting image to compare
show_image(soaps_image, "Original")
show_image(edge_sobel, "Edges with Sobel")
Edit and Run Code