LoslegenKostenlos loslegen

Apply thresholding

In this exercise, you will decide what type of thresholding is best used to binarize an image of knitting and craft tools. In doing so, you will be able to see the shapes of the objects, from paper hearts to scissors more clearly.

Several tools for handcraft art
Image loaded as tools_image.

What type of thresholding would you use judging by the characteristics of the image? Is the background illumination and intensity even or uneven?

Diese Übung ist Teil des Kurses

Image Processing in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the appropriate thresholding and rgb2gray() functions.
  • Turn the image to grayscale.
  • Obtain the optimal thresh.
  • Obtain the binary image by applying thresholding.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Import threshold and gray convertor functions
from skimage.____ import ____
from skimage.color import ____

# Turn the image grayscale
gray_tools_image = ____

# Obtain the optimal thresh
thresh = ____(gray_tools_image)

# Obtain the binary image by applying thresholding
binary_image = gray_tools_image > ____

# Show the resulting binary image
show_image(binary_image, 'Binarized image')
Code bearbeiten und ausführen