Help with batch processing using image calculator

Hi, i’m currently new with doing macros in imagej. Please help me with the code that I am currently doing right now. I want to have the original photo and add it up with the current outline summary of the image processing:

run(“16-bit”);
run(“Subtract Background…”, “rolling=10 light”);
run(“Auto Threshold…”, “method=Triangle ignore_black white”);
run(“Watershed”);
run(“Analyze Particles…”, “size=100-Infinity show=Outlines display clear include summarize”);
run(“Invert LUT”);
run(“Red”);
run(“Invert LUT”);
run(“RGB Color”);
-----> the results of the analyze particles will show up here. Then i need to open the original photo again and do an image calculator with it…

run(“RGB Color”);
imageCalculator(“Add create”, “img2”,“img1”);

-----> Then save the image calculator file to another folder.

Thank you very much!

Good day,

did you try using the Macro Recorder functionality of ImageJ? It will help you with coding.

I don’t think that the code parts you’ve posted work in a satisfying fashion.

This code line

run("Auto Threshold...", "method=Triangle ignore_black white");

appears being an invalid call (Fiji with IJ-version 1.52i).
It should read:

run("Auto Threshold", "method=Triangle ignore_black white");

But there is more …

Regards

Herbie

Yes, i did the macro recording:

Here is the whole script:open

(“G:/Cell Culture SAS/12112018/Day 4.jpg”);
run(“16-bit”);
run(“Subtract Background…”, “rolling=10 light”);
run(“Auto Threshold…”, “method=Triangle ignore_black white”);
run(“Watershed”);
run(“Analyze Particles…”, “size=100-Infinity show=Outlines display clear include summarize”);
open(“G:/Cell Culture SAS/12112018/Day 4.jpg”);
selectWindow(“Drawing of Day 4.jpg”);
run(“Invert LUT”);
run(“Red”);
run(“Invert LUT”);
run(“RGB Color”);
imageCalculator(“Add create”, “Drawing of Day 4.jpg”,“Day 4-1.jpg”);
selectWindow(“Result of Drawing of Day 4.jpg”);

I just wanted to use this protocol in batch processing by making the file names being a general code.

Does this first part

run("16-bit");
run("Subtract Background...", "rolling=10 light");
run("Auto Threshold...", "method=Triangle ignore_black white");
run("Watershed");

of your code run as desired on a typical image of yours?

Please check and report back

Herbie

yes it does, there seems to be no problem at all

This is really strange!

Could you please post what the macro recorder exactly tells you when you go to:

“Image >> Adjust >> Auto Threshold”

with:
sShot

Regards

Herbie

Capture

Here it is.

Interesting, it gives me:

run("Auto Threshold", "method=Triangle ignore_black white");

Anyhow, if you

just wanted to use this protocol in batch processing by making the file names being a general code.

you need to get either the image name

name = getTitle();

or the image ID

imgID = getImageID();

that are described here:
https://imagej.nih.gov/ij/developer/macro/functions.html

You can then use either in the calculator, for example like this:

imageCalculator("Add create", imgID-1, imgID-2);

HTH

Herbie