Aan de slagGa gratis aan de slag

Contouring shapes

In this exercise we'll find the contour of a horse.

For that we will make use of a binarized image provided by scikit-image in its data module. Binarized images are easier to process when finding contours with this algorithm. Remember that contour finding only supports 2D image arrays.

Once the contour is detected, we will display it together with the original image. That way we can check if our analysis was correct!

show_image_contour(image, contours) is a preloaded function that displays the image with all contours found using Matplotlib.

Shape of a horse in black and white

Remember you can use the find_contours() function from the measure module, by passing the thresholded image and a constant value.

Deze oefening maakt deel uit van de cursus

Image Processing in Python

Cursus bekijken

Oefeninstructies

  • Import the data and the module needed for contouring detection.
  • Obtain the horse image shown in the context area.
  • Find the contours of the horse image using a constant level value of 0.8.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Import the modules
from skimage import ____, ____

# Obtain the horse image
horse_image = ____.horse()

# Find the contours with a constant level value of 0.8
contours = measure.____(____, ____)

# Shows the image with contours found
show_image_contour(horse_image, contours)
Code bewerken en uitvoeren