Hello,
I am a developer and new to ImageJ and by no means claim an understanding of its use, however I was trying to do something that I thought would be relatively straight forward.
I have a working macro that I was attempting to turn into a python script that could be run from the command line, headless.
I ran into an issue that has me stumped.
The following code is stored in a file called “simple.py”: (note the entire macro does more than this, but I have limited to the salient code)
from ij import IJ
imp = IJ.openImage("C:\\Users\\me\\Fiji.app\\IMG_0723.JPG")
IJ.run(imp, "Hue Colours", "white_min=200 black_max=100 tolerance=10 light_dark_threshold=0.50
saturation_min=0.10 _white _red _greenyellow_light _aqua _orange _greenyellow_dark_ _grey _brown
_green_light_ _yellow_light_ _green_dark_ _magenta _yellow_dark_ make")
IJ.run(imp, "8-bit", "")
imp.show()
IJ.run("Dilate")
When I run “ImageJ-win64.exe --ij2 --headless --console --run simple.py”, I receive the error “There are no images open”.
When running the same code via the ImageJ GUI scripting console, it works.
I have tried changing IJ.run("Dilate")
to IJ.run(imp, "Dilate")
but that complains that the args are not a string.
I think what is happening is that “Dilate” wants to run on the active image window, but doesn’t support having an image object passed to it. If this is true, how can I make this work in a headless scenario?
Thanks in advance for the help. I have been searching and reading for hours and can’t seem to find an existing example of this issue.