Session Ready
Exercise

Apply global thresholding

In this exercise, you'll transform a photograph to binary so you can separate the foreground from the background.

To do so, you need to import the required modules, load the image, obtain the optimal thresh value using threshold_otsu() and apply it to the image.

You'll see the resulting binarized image when using the show_image() function, previously explained.

Chess pieces
Image loaded as chess_pieces_image.

Remember we have to turn colored images to grayscale. For that we will use the rgb2gray() function learned in previous video. Which has already been imported for you.

Instructions
100 XP
  • Import the otsu threshold function.
  • Turn the image to grayscale.
  • Obtain the optimal threshold value of the image.
  • Apply thresholding to the image.