Headless mode doesn't show opened file in ImageJ Macro



I have the following code which work fine when I executed under FIJI windows (copy paste)

run("Set Scale...", "distance=50 known=100 pixel=1 unit=um global");
run("Gaussian Blur...", "sigma=5");
run("Find Edges");
run("Enhance Contrast...", "saturated=0.4 normalize equalize");
run("Morphological Filters", "operation=Closing element=Disk radius=3");
setAutoThreshold("Minimum dark");
setThreshold(91, 255);
run("Analyze Particles...", "size=10000-Infinity display clear include summarize add");

Namely they show the image windows, etc.:

However when I save the exact code as my_macro.ijm
Then execute it the following way from command line interface

/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx my_macro.ijm


/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx --headless --console -macro my_macro.ijm

It produces nothing.

What’s the right way to do it?

This is mypict.tif:


Hi @Peverall_Dubois,

That is exactly what headless is supposed to do - not show any graphical interface or images on the screen. If you want to see the results / fiji gui, don’t use the --headless flag.

It looks like you’re just missing the -macro flag in your first attempt. I expect that this:

/Applications/Fiji.app/Contents/MacOS/ImageJ-macosx -macro my_macro.ijm

will work as you expect.

Let us know how this goes,