Wednesday, March 25, 2020

Thresholding in Computer Vision

Image segmentation is a key process in computer vision applications. It is used to partition an image into different regions and those regions correspond to real world objects extracted from the background. Image segmentation is very useful in image recognition and content analysis. Image thresholding is a simple image segmentation method.

Image thresholding is all about binarization of image. Binarization of  image means colored image is converted to black and white image by applying certain threshold on the pixel intensity. Binary image is different from gray scale image. In Gray scale images we have various shades of gray. But in binary image we have only 2 colors black & white.

The process of thresholding involves comparing each pixel of an image with predefined threshold value. This type of comparison of all pixels of an image with the predefined threshold value divides the entire image into 2 groups. One group involves pixels having intensity value greater than threshold value and another group consists of pixels having intensity value lower than threshold. 

Thresholding helps us in:
1.  Image binarization
2. Foreground objects extraction.
3. Background objects extraction

After extracting foreground  and background objects , these objects could be fed to machine learning models to identify what those objects are. Thresholding could also be used to create sketch like presentation of colored image.


Figure 1: Grayscale image




Figure 2:  Binary Image


Here is an example of how can we extract the foreground object from an image. As shown in figure 1 there is a picture of person with lake and mountains in the background. After applying thresholding on figure 1 , we could extract the person in the foreground and  not the background.

Figure 3: Original image                                  Figure 4: Image without background

 



We could also apply inverse of the thresholding and just keep the background and remove the  foreground object.