Created a macro to convert to binary, but it doesn't use the threshold I want - looking for help

Here is the macro:

//setThreshold(0, 100);
setOption("BlackBackground", true);
run("Convert to Mask", "method=Default background=Light black");
run("Fill Holes", "stack");

Pretty straightforward, all of my images work well with a threshold at value 100 and I just want to make them binary and open the save dialogue so I can type a new name for the Binary versions.

However, when I run the macro, it never actually uses threshold 100. It seems to consistently use a higher one, resulting in a ton of artifacts and false positives.

Any ideas how to fix this? I was hoping this would be a very simple macro to make

The macro recorder records this with two slashes // which means it’s a comment and will not be executed. Usually you will have recorded another line just before that either using one of the thresholding algorithms, or manually setting the threshold using the Set button. This comment is recorded merely to give you the option to un-comment it by removing the two slashes (but the recorder is programmed to act defensively because it cannot know what’s your intent here).

To get a better understanding of the macro language, have a look at the documentation:

and also here.


Thanks for your help!