I am developing Fiji macro written in Jython and I have a big problem with ThresholdAdjuster class.
In my macro I analyse series of images, and I would like to use ThresholdAdjuster on the first one and apply the chosen value for the rest of the images. That is I would like to choose it manually only on the first image. However I have three problems:

I have no idea how to read the threshold value from ThresholdAdjuster

How can I close the theshold window once Apply button is clicked?

If I change the default threshold (that is if I move the bar) even when i close the threshold window my macro stops working. Is there any command to make in continue working?

Thank you very much for help and your time.
However something strange is going on here. I have copied your macro and it shows 255 for both thres_min and thres_max. Honestly I have no idea why is that.
One more question - do you know how to automatically close threshold window once “Apply” is clicked?

kind regards,
Maciej

EDIT: OK I found the answer for the first question. Once “apply” is clicked it shows 255 for both values. So “OK” in dialog window should be clicked first. Unfortunately that functionality is not the best, but still better than nothing:)

EDIT2: I got it working! It does all I need now. Thank you very much for your help, you’re the best:)