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
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Segmentation and binary images1m 38s
-
(Locked)
Simple thresholding6m 34s
-
(Locked)
Adaptive thresholding4m 38s
-
(Locked)
Skin detection6m 31s
-
(Locked)
Introduction to contours1m 38s
-
(Locked)
Contour object detection6m 56s
-
(Locked)
Area, perimeter, center, and curvature8m 19s
-
(Locked)
Canny edge detection8m 1s
-
(Locked)
Object detection overview1m 59s
-
(Locked)
Challenge: Assign object ID and attributes50s
-
(Locked)
Solution: Assign object ID and attributes10m 5s
-
-
-