/  Deep Learning Interview questions and answers   /  How can we do Thresholding in Computer Vision using OpenCV?
Computer vision (i2tutorials)

How can we do Thresholding in Computer Vision using OpenCV?

Thresholding is the assignment of each pixel in an image to either a true or false class based on the pixel’s value, location or both. The result of a thresholding operation is typically a binary image in which each pixel is assigned either a true or false value. The simplest thresholding methods replace each pixel in an image with a black pixel if the image intensity {\displaystyle I_{i,j}} is less than some fixed constant T or a white pixel if the image intensity is greater than that constant. In the example image on the right, this results in the dark tree becoming completely black, and the white snow becoming completely white. To make thresholding completely automated, it is necessary for the computer to automatically select the categorize thresholding methods into the following six groups based on the information the algorithm manipulates Histogram shape-based methods, where, for example, the peaks, valleys and curvatures of the smoothed histogram are analyzed

Clustering-based methods, where the gray-level samples are clustered in two parts as background and foreground (object), or alternately are modeled as a mixture of two Gaussians

Entropy-based methods result in algorithms that use the entropy of the foreground and background regions, the cross-entropy between the original and binarized image, etc.

Object Attribute-based methods search a measure of similarity between the gray-level and the binarized images, such as fuzzy shape similarity, edge coincidence, etc.

Spatial methods [that] use higher-order probability distribution and/or correlation between pixels

Local methods adapt the threshold value on each pixel to the local image characteristics. In these methods, a different T is selected for each pixel in the image.

Code for Thresholding in Computer vision using OpenCV

Open CV1 (i2tutorials)

Open CV 2 (i2tutorials)

Leave a comment