# Thresholding methods - How to choose wisely?

Hello everyone,
I am trying to find the best way to do a thresholding for my image analysis. I am going to use this site [https://imagej.net/Auto_Local_Threshold] as a reference.
I have a computed tomography image with a bit of noise. The global thresholding is more or less good, but I think it is possible to do it better with the local thresholding.
I have carefully read the explanations on every method, but not everyhing is clear. Even when it’s clear, I always have to do the old “try and error”.

1. My instint says Otsu is the answer, but I don’t understand at all how this one works. Ive seen this method is good for bipolar and noisy images. But when I use it, it’s just a mess. How does it work?
2. The mean/median method takes the mean/median of the local greyscale distribution and can be adjusted with a constant C1. Niblack is similar to the mean method; it has a correction value (with the standard deviation). Sauvola is based on Niblack and has a parameter “r” empirically set. Midgrey is similar, taking instead of the mean/median the (max + min)/2 of the local values. The contrast method compares the pixel with the max or min and sets it to the one closest.
All of this methods give me poor results. I have used them succesfully to correct an image of a poorly iluminated image (for practice). The noise is probably messing with the results. Is there a way to surpass it?
3. I have not understand the Bernsen method. Can you help me? I understand the words, but not the process.
Phansalkar is a modification of Sauvola that I don’t really understand, but my instinct tells me this is not the one. But what does my instinct know…
Thank you all so much.
1 Like

That problem is not easy to resolve generically. You probably need to investigate the histograms of your images before deciding on a particular global thresholding method.
The “Try All” option was added as a lazy way of testing what might work with a given image, but it is a bit like going fishing, there is no guarantee that it will result in anything useful.
The local thresholding methods tend to be best when you know the size of the objects you are trying to detect (most of those have been developed for text segmentation in documents), but not so good when you have lots of background (they can “find” features when there are none).
To answer your other question, you could try reducing noise with some low pass filtering (Gaussian, Mean, or via FFT filtering), then apply the thresholding to the filtered image.
Hope it helps a bit.

1 Like

I will try the filters.
I read some of the papers but it wasn’t all clear for me. But that’s ok, I will try another way.
Thank you

Hi @Diego_Hens,

Without having seen the image, I would second what @gabriel mentioned on the preprocessing.

Generally, a median filter with a radius of 1 pixel has a strong noise reducing potential.

That said, you might want to try to run the the Threshold Check on you image after pre-processing.

This will first of all give you the possibility to compare all global as well as local auto thresholds implemented by @gabriel in his nice plugins.
Because I think just looking at the histogram properties might still not tell you how well a certain threshold will perform on a particular image. Second, you can even use the quantification possibility of the Threshold Check to get a more objective relative comparison of all thresholds.

Hope that makes the final decision a bit easier

2 Likes

Hello,