Adjusting brightness contrast in imagej

I want to use the auto-threshold tool to separate pores and the solid particles from my sample. I was adjusting brightness and contrast for the same sample differently for different times and getting different gray values for my image. I don’t want this. I want my gray values to remain unchanged irrespective of what brightness and contrast I set. How can I do that?

So if you use: Image > Adjust > Brightness / Contrast
And only the Buttons: Auto, Reset, Set then the grey values are unchanged.

ONLY If you use the button Apply the histogram will be re-scaled. So just don’t use the Apply button.

3 Likes

I never used the “apply” button to get the same gray value. But, when I am using auto local thresholding in the same sample, I am getting different results based on how I adjust the brightness and contrast. However, it seems that the gray values remain pretty much the same irrespective of how I adjust the brightness and contrast. In brief, I am not able to reproduce my results using the same thresholding parameters.

Hm that is strange. If I try to reproduce this with a 8-bit sample image (blobs) using the auto-threshold or the local autothreshold I get the same results for all the thresholding methods.

Could you maybe record the steps using the macro recorder so we could reproduce this? Maybe I overlook a detail.

I use Linux ImageJ 2.0.0-rc-69/1.52p; Java 1.8.0_66

1 Like

Both of the gray images (soil) are the same sample but I adjusted the brightness and contrast differently, which can pretty clearly be seen as well ( I didn’t press any submission button). After that, I converted both of the 2 samples to 8 bit and used the Phansalkar auto local threshold with a radius of 6 and default parameters.
The two thresholded images clearly show that they are different in terms of pore spaces (the black portion). The marked black spot (inside orange) is actually a PVC rod that is read as air space on the 2nd image which is a huge error.
I have also shared the macro recordings that might be of some reference.

Thanks,
Suman

auto threshold macros.txt (568 Bytes)

From https://imagej.nih.gov/ij/docs/menus/image.html:

ImageJ converts 16-bit and 32-bit images and stacks to 8-bits by linearly scaling from min-max to 0-255, where min and max are the two values displayed in the Image>Adjust>Brightness>Contrast tool. Image>Show Info displays these two values as the "Display range". Note that this scaling is not done if "Scale When Converting" is not checked in Edit>Options>Conversions.

Convert first, adjust brightness/contrast after (or uncheck “Scale when converting”) and that should make things consistent!

4 Likes