Skip main navigation

Thresholding in Fiji

An overview of the auto-thresholding algorithms available in Fiji

In the previous article, we introduced the technique of binary thresholding, describing a classical approach, Otsu thresholding, and showing how to do this using Fiji. In this article we look at some of the other thresholding algorithms available in Fiji and briefly discuss their applications and assumptions.

Auto-thresholding in Fiji

As we have seen, its easy to threshold an image using Fiji. First, convert to grayscale (unless it is already) using Image -> Type -> 8-Bit, then select Image -> Adjust -> Thresholding. After this, it is just a matter of selecting the type of thresholding and options that best fit your image data and type of analysis required.

We’ve already looked at Otsu which usually works well when your image has a clear bimodal distribution of two regions such as similarly coloured objects on a uniform background. But what about the other thresholding applications in Fiji? You can find a list of them linked below, along with descriptions. We will show the results of each using examples (or an example), and describe how a few of the methods work.

First Example

Take a look at the images below, showing (left to right) an RGB colour image of a leaf, the grayscale version of the same image, and the histogram showing the distribution of pixel intensities.

A colour image of a leaf, next to a grayscale version, and the grayscale image histogram produced in Fiji showing the distribution of pixel intensities.

Remember that what binary thresholding does is select a value to divide the image into two subsets of pixels, and so all any thresholding algorithm does is calculate where to place this dividing line for a given image – which intensity level to use as a decision point. You can think of this as placing a dividing line on the image histogram, and different algorithms will place this diving line in different places resulting in different results.

The reason we have different algorithms is they will assume the image data is distributed in different ways. For example, some algorithms will assume a certain percentage of the image is foreground, or that the image data forms a bi-model histogram (ie. has two peaks).

The figure below shows the results of each of the algorithms available in Fiji at the time of writing. Note that the box for ‘Dark Background’ was selected so that the object of interest (the leaf in this case) appears white on a black background. Some methods select all the pixels within the leaf, but also select areas that are the shadow of the leaf on the background. Other methods pick out the outline of the leaf clearly, but miss out parts of the stem, veins, and the brightest parts of the leaf.

A demonstration of all the auto-thresholding algorithms in Fiji applied to an image of a leaf. The results vary in effectiveness, but all show a pure white shape on a black background.

The simplest type of methods just use a simple measure such as the mean pixel intensity (Mean), or selecting a threshold so that 50% of the pixels fall in each category (Percentile). The ImageJ help files provide helpful overviews of all the implemented approaches.

How to choose a thresholding algorithm

This is a difficult question to answer and depends both on your image data and on what you are trying to measure. In the image used above for example, while some methods clearly are less suited to the problem, with others it is not so clear cut. Is it important that the outline of leaf is captured exactly? Or is more important to ensure all pixels within the interior of the leaf are classified as such (ie. no speckles of background pixels in the foreground region)? This will depend on the purpose of your experiment. If you have large data set with many images it’s always worth trying out a few methods with a few different images to ensure the thresholding method you pick is suited to your analysis. Care must be taken when thresholding as changes in e.g. lighting or orientation of the camera might change the assumptions of the algorithm in use, therefore causing thresholding to fail.

Is binary thresholding always suitable?

Have a look at the images, histogram and thresholding results show below. Can you explain why binary thresholding is probably not the best method of capturing all the pixels of the “object” shown in the image?

A colour image of a black and white cat on some grass, next to a grayscale version, and the grayscale image histogram produced in Fiji showing the distribution of pixel intensities.

A demonstration of all the auto-thresholding algorithms in Fiji applied to an image of a cat. The results vary in effectiveness, but all fail to select the black patches on the cat, and some have selected patches of the grass background.

This article is from the free online

Introduction to Image Analysis for Plant Phenotyping

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education