Image binarization (1) : Introduction

Image binarization is the process of taking a grayscale image and converting it to black-and-white, essentially reducing the information contained within the image from 256 shades of gray to 2: black and white, a binary image. This is sometimes known as image thresholding, although thresholding may produce images with more than 2 levels of gray. It is a form or segmentation, whereby an image is divided into constituent objects. This is a task commonly performed when trying to extract an object from an image. However like many image processing operations, it is not trivial, and is solely dependent on the content within the image. The trick is images that may *seem* easy to convert to B&W are many times not.

How does it work?

The process of binarization works by finding a threshold value in the histogram – a value that effectively divides the histogram into two parts, each representing one of two objects (or the object and the background). In this context it is known as global thresholding (we’ll talk about local thresholding later). Here’s an example of a plane spotters card from WW2 (left), thresholded using Otsu’s algorithm (right).


Most thresholding algorithms work by using some type of information to make a decision about where the threshold is. Sometimes the information is statistical and uses the mean, median, entropy, other times information is in the form of shape characteristics of the histogram. Otsu’s algorithm is one of the classical thresholding algorithms introduced by  Nobuyuki Otsu in 1979 [1]. The algorithm works by exhaustively searching for the threshold that minimizes the weighted within-class variance, or put anther way maximizes the between-class variance. (I’ll discuss this classic algorithm in a future post).

The threshold calculated is 126, shown in combination with the histogram. To binarize the image, pixels less than 126 are set to 0, whilst pixels >= 126 are set to 1 (or 255 if you want to view it). Notice that the object is often shown as black, and the background as white. One might consider this counter-intuitive, however objects often appear as dark entities on a white background, so it is not unrealistic. Regardless of the algorithm used, the quality of the result ultimately depends on the complexity of the image. Images with simple objects are more likely to be successfully segmented than those with many varied objects.

There are literally hundreds of thresholding algorithms in the literature, but none to date work in a generic manner, i.e. can be applied to any image with a satisfactory result.

[1] Otsu, N., “A threshold selection method from gray-level histograms”, IEEE Trans. Systems, Man, and Cybernetics, 9(1), pp.62–66 (1979)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s