Skip main navigation

# Otsu Thresholding

A description of Otsu thresholding

## Segmentation

In many cases, especially when dealing with experimental images, you are dealing with a picture of a one or more discrete objects on a relatively plain background. If you are primarily purely interested in the size and shape of those objects, or to count them, one approach to try is binary segmentation. As the name suggests, this process divides or segments the pixels of a grayscale image into two subsets or clusters.

Generally, binary segmentation takes the form of a threshold value. Every pixel brighter than the threshold is placed in one subset and assigned the value 255 (if it is an 8-bit grayscale image), while every pixel below the threshold is placed in the other and assigned the value zero. Then the objects of interest will be all the pixels with the value 255 or 0 (depending respectively on whether the image shows a bright object on a dark background or a dark object on a bright background).

## Otsu’s method

While the basic principle of threshold binary segmentation is simple, there are numerous different methods used to select the numerical threshold value for a given image. One common automated approach is Otsu’s method, named after Nobuyuki Otsu, the author of the paper in which it was first described (Nobuyuki Otsu (1979). “A threshold selection method from gray-level histograms”. IEEE Trans. Sys. Man. Cyber. 9 (1): 62–66.)

In summary, Otsu’s method looks at every possible value for the threshold between background and foreground, calculates the variance within each of the two clusters, and selects the value for which the weighted sum of these variances is the least. Alternatively , it is also possible to consider the variance between the clusters. Minimizing intra-cluster variance (within cluster variance) and maximising inter-cluster variance (between cluster variance) give the same result, and suggest a good split between the two classes.

## Otsu segmentation in Fiji

A quick way to see how this works is to look at an example in Fiji, here’s the image ‘NileBend.jpg’ from Fiji’s sample images (look in File -> Open Samples -> Nile Bend) . The first thing to remember is that to use Otsu’s method you need a grayscale image, so we need to change the image to 8-bit using Image -> Type -> 8-bit.

To visualise the range of pixel intensities present in the image we have shown the image histogram using Analyse -> Histogram within Fiji’s menus. The histogram plots the number of pixels for a given grayscale intensity for each of the possible values from 0 to 255. There two obvious peaks in intensity, one at around 40 corresponding to the dark fertile region near the river, and another, higher peak at around 210 corresponding to the brighter, more arid regions away from the river. The peak corresponding to the brighter pixels is higher because a greater proportion of the picture is showing the brighter regions.

It’s easy to perform Otsu’s method using Fiji, just select ‘Image -> Adjust -> Threshold’, then in the window that pops up make sure ‘Otsu’ is selected is the dropdown box.

## An experimental example

For another example, look at the example below showing a plant root system on a plain coloured background.

Here there is just one obvious peak visible in the histogram, at around 150 intensity, corresponding to the image background. If you look closely however, there are also a number of brighter pixels just visible in the histogram to the right of the background peak (around 200 intensity) corresponding to the brighter plant roots.

Because the background pixels are much more numerous than the pixels showing the root, the peak on the histogram for the background dwarfs the values corresponding to the roots.

Again, when we perform Otsu segmentation on this image, the algorithm appears to have done a good job of separating out all the pixels of the image containing plant roots. If, for example, we wanted to estimate the total area of the root system, we could calculate this directly by counting the pixels equal to one and using the image scale. If, on the other hand, we wanted to do something more sophisticated like count the number of roots, or measure the length of individual roots, this segmentation step can be a useful first step in an image analysis pipeline.

Feel free to experiment with Otsu and some of the other binary image segmentation methods within Fiji, using the attached images, as well as your own. As you do so, consider what some of the pitfalls of experimental imaging practices might be when performing segmentation of this kind. Also bear in mind that using automated approaches in inappropriate situations, where the data doesn’t meet the assumptions of the algorithms, can lead to poor quality and erroneous results.

This article is from the free online

Created by

## Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now