Aan de slagGa gratis aan de slag

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?

Deze oefening maakt deel uit van de cursus

Image Processing in Python

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# 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 bewerken en uitvoeren