setAutoThreshold fails

I am trying to threshold a signed 16 bit stack, and have distilled my problem down to the following macro:

setAutoThreshold (“Otsu dark stack”);

This is what I get from the macro recorder when I set the threshold interactively (Image>Adjust>Threshold), in which case it seems to work fine (thresholds are [-767,32767] for example). But when I run it as a macro it sets the thresholds to [-32768,-27828]. If I remove “dark” I get [-32768,-33555]. If I remove “stack” it works fine (although it appears to use only the histogram from the current slice). The anomalous results seem to be independent of the thresholding method. In fact it doesn’t seem to matter what I put in for method (“Trump” for instance).

Any advice would be appreciated. Apologies if this is answered elsewhere - I’ve searched.

Fiji, ImageJ 1.52p, Windows 10, x64

Could you post the image so we can try to replicate this issue?

auto_threshold.tif (512.2 KB)

I have uploaded one slice. I hadn’t tried it before, but the behavior is reproduced with this. (The upper threshold seems to vary with the number of slices.)

I have tried taking a look but I don’t know enough about ImageJ to determine the exact issue. However, what I have been able to determine is that it probably is the result of the GUI and macro methods dealing with the display range. The macro seems to be thrown-off by the large concentration of -2048 that results from the image’s display range.

I wonder if the greyscale calibration (which uses a negative value as minimum) is the source of the confusion.
If you remove the calibration, Analyze>Calibrate: None, then the histogram seems to show positive values only.
Can you please retry your macro after removing the calibration and see what results do you get.

1 Like

That does seem to do the trick. Thanks to all for looking at this.

I guess this would constitute a workaround, since the interactive version does seem to work.