Change Threshold method selected in the Threshold window from a macro

Hello to all,

I want to threshold an image from within a macro with a certain threshold method - this works fine. However, I need to give the user the oportunity to fine tune the settings. Therefore the Threshold window is opended. Although the image is thresholded with the method of choice (Triangle in this example) this method is not selected in the Threshold window. This would be very nice to have, because the user could simply click on Auto to get back to where the threshold was before (in case fine tuning was not successfull).
In the following example the image is thresholded with the Triangle method, but the method shown in the Threshold window is “Default” (or whatever was selected manually the last time):

run("Blobs (25K)");
setAutoThreshold("Triangle");
run("Threshold...");

Is there a way to select Triangle from the macro?
Thanks,
Martin

Hi Martin,

I quickly checked the source code of the threshold adjuster, and realized there is no way to programmatically set the auto-threshold method.

http://imagej.net/developer/source/ij/plugin/frame/ThresholdAdjuster.java.html

If @Wayne has the time and will, maybe he could make it possible?

Best
jy

2 Likes

jy, thank you for looking this up. Good to know that it is useless to try all kinds of different things. Let´s see if Wayne hat the time and the will. But it is definitely not an important or urgent issue …
martin

The ImageJ 1.50d13 daily build adds a static setMethod() method that can be called from a macro to set the auto-threshold method. Here is an example:

run("Blobs (25K)");
method = "Otsu";
setAutoThreshold(method);
call("ij.plugin.frame.ThresholdAdjuster.setMethod",method)
run("Threshold...");
3 Likes

Perfect! Thank you Wayne.