Thresholding

Learn about binarizing an image with the thresholding operation: simple threshold, inverse threshold, and Otsu algorithm.

If you ask me what image operation is most often used when writing automated inspection programs, I would answer thresholding without hesitation. Thresholding is the image transformation into a binary image, or multiple binary channels according to a pixel-wise binary test.

When the output of a thresholding operation is a binary image—a monochrome image taking only two possible values, typically 0 or 255—we call this image a mask. This naming convention reflects the idea that we want to highlight the regions of interest in the image where the mask is active, usually white, and ignore areas where there is no useful information for our task.

Simple threshold

The simplest form of thresholding is to apply the following rule to a grayscale image:

Get hands-on with 1200+ tech skills courses.