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.

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?
This exercise is part of the course
Image Processing in Python
Exercise instructions
- Import the appropriate thresholding and
rgb2gray()
functions. - Turn the image to grayscale.
- Obtain the optimal thresh.
- Obtain the binary image by applying thresholding.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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')