CommencerCommencer gratuitement

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?

Cet exercice fait partie du cours

Image Processing in Python

Afficher le cours

Instructions

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

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# 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')
Modifier et exécuter le code