Trying other methods
As we saw in the video, not being sure about what thresholding method to use isn't a problem. In fact, scikit-image provides us with a function to check multiple methods and see for ourselves what the best option is. It returns a figure comparing the outputs of different global thresholding methods.

Image loaded as
fruits_image
.
You will apply this function to this image, matplotlib.pyplot
has been loaded as plt
. Remember that you can use try_all_threshold()
to try multiple global algorithms.
This exercise is part of the course
Image Processing in Python
Exercise instructions
- Import the try all function.
- Import the rgb to gray convertor function.
- Turn the fruits image to grayscale.
- Use the try all method on the resulting grayscale image.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Import the try all function
from skimage.____ import ____
# Import the rgb to gray convertor function
from skimage.____ import ____
# Turn the fruits_image to grayscale
grayscale = ____
# Use the try all method on the resulting grayscale image
fig, ax = ____(____, verbose=False)
# Show the resulting plots
plt.show()