Can't get macros to work

macrorecorder
batch-processing
imagej
macro
fiji
Tags: #<Tag:0x00007fd699d46620> #<Tag:0x00007fd699d464e0> #<Tag:0x00007fd699d463a0> #<Tag:0x00007fd699d461e8> #<Tag:0x00007fd699d46080>

#1

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:

Starting:

Adjusted:

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:

run("8-bit");
//run("Brightness/Contrast...");
setMinAndMax(46, 199);
run("Apply LUT");
run("Close");
setAutoThreshold("Default dark");
//run("Threshold...");
setOption("BlackBackground", false);
run("Convert to Mask");
run("Close");
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!


#2

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");.

Best,
Stefan