Thresholding with or without brightness/contrast adjustment

Can anyone suggest me best thresholding for this image slice?iuppp.tif (8.2 MB) Grey represents soil, black represents the pores and white represents stones.
It is a 16-bit image and I am doubtful in adjusting brightness and contrast of this image but doing so improves my thresholded results.

Hello Suman56,
This is an image stack. Do you want to threshold all of the images, or only the first one? Are you wanting to make it 3D? And which of the three options are you interested in?

1 Like

Hi Robert,
Yes, I want to threshold all of the images.
I am interested only in quantifying the pores and making it 3D.


O.K., I will check them out and let you know more tomorrow, it’s late here.

1 Like

Hi @Suman56,

this is more a general thing than a really image related problem.
If you adjust the contrast, you principally separate the intensity values more from each other. They will have a higher difference and thus can be better distinguished (by eye as well as by many thresholding methods). This is why you might see an improvement of the segmentation result.
Brightness adjustment just adds or subtracts the same value to/from every pixel and thereby has less/little benefit for thresholding.

But since you mention, you have doubts about it, I guess it is rather about if you can use this method at all(?)

As a preprocessing technique to achieve a better segmentation result contrast adjustment is a perfectly valid method. Important is, that the contrast adjustment is done exactly the same for all your images in the experiment to be comparable. Here, you will have to take care with non-linear contrast adjustments like histogram equalization and gamma, since those destroy the original intensity relations and thus introduce a certain bias.


Hello again,
With only 31 images, that is only a 6% thickness to width ratio. Regardless of what you do it will not be very thick so if you decide to use the 3D viewer (in Plugins) I would recommend display as Multiorthoslices
I used k-means clustering set to 8 clusters, and the 8 color LUT.
Finally you could simply Threshold it around the 83-97 peak values and then invert the image. This will give you only the pores.With the 3D viewer use the yellow color to make it brighter.(Suman56inv)
No brightness,contrast adjustments were made.
Good Luck,
Suman56_k-means cluster centers.csv (108 Bytes)
Suman56A Clusters.tif (8.2 MB)
Suman56inv_stack.tif (8.2 MB)

hi @biovoxxel,

Thanks for the suggestion. The reason I am doubtful about this is that my results will be based on a particular level of brightness and contrast. If someone else uses different brightness and contrast, which he feels better, then our result will never match.


Hi @smith_robertj,

Sorry, I forgot to mention that I just extracted 31 slices out of 1000 slices that I have, since I was having trouble uploading the full stack.
Thank you for your help.
To get the same inverted stack as yours, I have to use a threshold value of 131. I am not familiar with K-clustering but I assume you are using it to segment between all different particles.
When I do a little bit of brightness and contrast adjustment, the pore number increases significantly, do you think that will be fine? Just cropping the outer diameter of my circular image, which is a PVC pipe and pressing the reset button, perfectly adjusts the brightness and contrast which I think should be valid.

Well I think if some other lab would have similar samples it would anyway not be comparable due to variations in the experimental conditions (I guess). Furthermore, you adjust the brightness/contrast only for the extraction of 2D or 3D objects (so your pores). If you additionally need the intensity inside the pores as a value indicating a specific material, then you definitely need to do that kind of measurement on the very original image without any adjustment of brightness/contrast otherwise it would really lead to alterations in the result.

I am interested in calculations like the number of pores, diameter, the surface area of pores and soon. I think differences in intensity will change these all significantly and so my final results. Right now, I am considering just using the Reset option, which I think is pretty much valid in my case? When I crop everything outside my region of interest and press the “reset” button, it gives me what I want. Not sure, but I think this will not alter my original intensity values.

Not sure if significantly but yes, it will have an influence on it. While equal processing of all images with exactly the same values should keep it comparable.
What I am not sure about is what exactly you mean with the reset. If you base your primary selection or exclusion on a changed brightness it has already an influence on the selection. If this just serves you to preselect your sample (the roundish object) and in a second step (after resetting the contrast) you run a thresholding, that will do it based on the original intensity values and not lead to any change.

In the first image, I just used the Reset button and get a display range of -3024 to 3071. When I first crop the outer greyish part, and then I “Reset” the brightness and contrast, I am getting a different range of -948 to 3071. Since these are a 16-bit image, converting them to a 8-bit before applying a local thresholding method will have some significant amount of differences. In the first, thresholding is not able to do a good job in segmenting all the pores as compared to the second one.

Hello there!

Yes, 1000 slices are much better to understand 3D data with.

When you go to Image > adjust >Threshold you will see the entire peak surrounding the value of
80 something to 135 something. Threshold the entire peak to get the results you wish.

If you use the magic wand on the tool bar and click on the PVC pipe, you can go to Edit > Clear Outside to clear the outside(naturally) with out needing to adjust brightness or contrast.

You may find that doing both techniques , both colored and thresholded will give you all the information you could wish from the images.

Again, Good Luck,


1 Like