Low intensity 32 bit data converted to high 16 bit data

imagej
32bit
image-calculator
16-bit

#1

Hello All,

I have a curious problem with my processing. My low-intensity 32 bit images are converted into high intensity values after a 16bit conversion. My normal-intensity values are fine to convert. Is anyone aware of a bug here? Is there a lower 32bit threshold that does something inverse to the data?

Below is an example of the results, where the negative control data are highlighted. It seems very specific for the low-intensity values, since the other values scale correctly.

Below is the image calculator macro I am running.

imageCalculator(“Subtract create 32-bit”, “RFP”,“Dark.tif”);
rename (“RFPSub”);
imageCalculator(“Divide create”, “RFPSub”,“MedianShade.tif”);
rename (“RFPcorrected”);
selectWindow(“RFP”);
close();
selectWindow(“RFPSub”);
close();
selectWindow(“RFPcorrected”);
run(“16-bit”); // THIS IS A BUG IT MAKES THE NEGATIVE VALUES MUCH HIGHER AFTER 16 BIT CONVERSION
selectWindow(“RFPcorrected”);

Any help would be much appreciated!

Cheers,

Darren


#2

Good day!

THIS IS A BUG IT MAKES THE NEGATIVE VALUES MUCH HIGHER AFTER 16 BIT CONVERSION

ImageJ handles 16bit as unipolar, i.e. no negative values.

Concerning conversions in general, please study the ImageJ user guide:
https://imagej.nih.gov/ij/docs/guide/index.html

Regards

Herbie


#3

When converting 32-bit images to 16-bit, ImageJ scales the values from min-max to the 0-65535 range, unless the Scale When Converting option is unchecked in Edit > Options > Conversions.

See the documentation:

Scale When Converting ImageJ will scale from min–max to 0–255 when converting from 16-bit or 32-bit to 8-bit or to scale from min–max to 0–65535 when converting from 32-bit to 16-bit. Note that Scale When Converting is always checked after ImageJ is restarted.


#4

Hi @Herbie @imagejan

Thanks for you comments.

Yes I tried the conversion tick box with bad results.

Looking at my excel sheet above, do you agree that it is strange, since all the other >0.1 values scale correctly?
My default solution now is to keep as 32bit data and express as relative % to eachother.

Thanks for all your help and time,

Darren


#5

Hi @Darren_Thomson,

I cannot reproduce your issue. I tried with this little macro:

newImage("Untitled", "32-bit black", 4, 4, 1);
setPixel(0,0,0.01);
setPixel(0,1,0.1);
setPixel(0,2,0.25);
setPixel(0,3,1.0);
setPixel(1,0,0.01);
setPixel(1,1,0.02);
setPixel(1,2,0.03);
setPixel(1,3,0.04);
setPixel(2,0,0.1);
setPixel(2,1,0.2);
setPixel(2,2,0.3);
setPixel(2,3,0.4);
setPixel(3,0,0.5);
setPixel(3,1,0.6);
setPixel(3,2,0.7);
setPixel(3,3,0.8);
run("16-bit"); // compare before and after this command

and everything works as expected. Would you have a minimal runnable code example to reproduce your issue?


#6

Sorry @Herbie, that message in my code is misleading. I meant that it is the ‘negative control’ values. None of my values become negative as you can see in the spreadsheet.


#7

I see …

Here is another macro that shows that the results are as described by Jan:

run("Conversions...", "scale");
run("Set Measurements...", "min redirect=None decimal=6");
newImage("Untitled", "32-bit black", 256, 256, 1);
makeRectangle(0, 0, 128, 256);
run("Set...", "value=0.05");
run("Make Inverse");
run("Set...", "value=0.50000");
run("Select None");
run("Duplicate...", " ");
run("16-bit");
run("Measure");
close();
run("Conversions...", " ");
run("16-bit");
run("Measure");
close();

The image has two parts, one of value 0.05, the other of value 0.5.
The first result is with scaled conversion (default), the second without scaling.

HTH

Herbie