From the course: OpenCV for Python Developers

Unlock the full course today

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

Introduction to contours

Introduction to contours

- [Presenter] Once you have segmented out the key areas of an image, the next step is typically to identify the individual objects. But how can we do that? One powerful way is to use OpenCV's implementation of contours. The goal of contours is to take a binary image and create a tightly fitting closed perimeter around all individual objects in the scene. Each perimeter is called a contour. From a mathematical point of view, it is called an iterative energy reduction algorithm, but conceptually, we can think of it as an elastic film that starts on the edges of an image and squeezes in around all the objects and shapes. It creates the boundary around all these objects. One thing to be aware of is the idea of neighborhoods and connectedness. Contours will consider any pixel value above zero as part of the foreground and any other pixels touching or connected to this pixel will be made to be part of the same object. As the…

Contents