From the course: OpenCV for Python Developers

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Simple thresholding

Simple thresholding

- [Instructor] With an understanding of segmentation and the importance of binary images, let's take a look at performing our own simple thresholding. First, we'll load in a black and white image. Do this we'll, type bw = cv2.imread and then we'll use detect underscore_blob.png. And then we are going to pass into value of zero explicitly. This will tell OpenCV to load it in as a black and white image. Next, let's get the height as well as the width by typing height width from the image = bw.shaped 0 to 2 to indicate we only want the first two values from the shape. Finally, let's go ahead and show this image using cv2.imshow, original, black white, end quote and then pass in the BW variable. Now the goal is to imple a straightforward thresh holding method to extract the objects from an image. We can do that by assigning all the objects a value of 1 and everything else a value of 0. To begin, we will initialize our…

Contents