Can't get macros to work



Hi, I’m really new to imageJ/Fiji and I’m trying to process a batch of images of bacterial counts so that I can count them. Here are examples of my starting and processed photos:



Essentially I just want to adjust the brightness/contrast a bit so that when I tranform the image into a binary image it will make an image that isn’t noisy so I can count the number of cells accurately.

I made a macro from plugins>macro>record, and attempted to run this macro on all the images through process>batch>macro. Here is the macro I recorded:

setMinAndMax(46, 199);
run("Apply LUT");
setAutoThreshold("Default dark");
setOption("BlackBackground", false);
run("Convert to Mask");
run("Analyze Particles...", "exclude summarize");

However, when I try to run this with a batch, I get an error message that either says “there are no images open” or (if I have all of the images I want to process open) it will say “A threshold image or 8-bit binary image is required”. This makes me very confused because they are supposed to be converted to an 8-bit image in the first step. If someone could explain how to write and run a macro that adjusts brightness/contrast, then converts to an inverted binary image for cell counts, that would be absolutely fantastic. Thanks!


Dear @jcomstock,

you have two stray invocations of run("Close") in your macro that will close the current image. Since all the other operations work in-place (they don’t create new images), you should achieve your desired result by removing the two lines with run("Close");.