From the course: OpenCV for Python Developers

Unlock the full course today

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

Solution: Assign object ID and attributes

Solution: Assign object ID and attributes

From the course: OpenCV for Python Developers

Solution: Assign object ID and attributes

(lively upbeat music) - [Instructor] Now let's take a look at one solution to this challenge. As a reminder, our goal is to segment out the objects in this fuzzy image only to draw the large objects and give each of them a unique color and print out their area. To do this, we'll move back to the exercise file. The first operation we want to do is to convert this image to gray scale so we can do all of our thresholding. Well, let's start by typing gray equals cv2.cvt, and then capital C for Color, and then we'll pass in our image, comma, and then cv2., in all caps, COLOR_BGR2GRAY, close parenthesis. Next, we'll use this little trick to actually help make our adaptor threshold work better by blurring our image. As we've done in the past, let's use a Gaussian blur by typing a blur equals cv2., capital G for A-U-S-S-I-A-N, Gaussian and then B-L-U-R where the B is capitalized. We'll pass in gray and then we'll use…

Contents