From the course: OpenCV for Python Developers

Segmentation and binary images

- [Instructor] In this chapter, we are focused on extracting features and objects from images. An object is the focus of our processing. It's a thing that we actually want to get to do further work. In order to get the objects out of an image, we need to go through a process called segmentation. Segmentation can be done through a variety of different ways, but the typical output is a binary image. A binary image is something that has values of zero or one. Essentially a one indicates the piece of the image that we want to use and a zero is everything else. Binary images are a key component of many image processing algorithms. These are pure non-alias black and white images, the results of extracting out only what you need. They act as a mask for the area of the source image. After creating a binary image from the source you can do a lot when it comes to image processing. One of the typical ways to get a binary image is to use what's called a thresholding algorithm. This is a type of segmentation that does a look at the values of the source image and a comparison against one central value to decide whether a single pixel or group of pixels should have a value of zero or one. And the top example on this slide, we can see that the binary threshold applied looks at every pixel and the image on the left to see if the value is greater than or equal to 128. If it is, it is assigned the value of one. Anything less than that is assigned the value of zero. On the bottom example, the binary threshold is based around the value of 64. Therefore, everything that has a value of 64 on the left hand image, is assigned to one. This is a very simple example of segmentation. We'll go more into it into the next steps and explore more advanced methodologies later in this chapter.

Contents