I am new to writing code (in general, as well as) in Macro scripting language, and could use your advice/help.
What I want to do: I want to run a plugin called Differentials JB with a specific operation of differentiate with respect to X or differentiate with respect to Y on 32-bit gray scale images that I have stored in a folder.
Steps in the Macro: I modified the code generated by the recorder macro option to write a macro. Specifically, for a list of files from a user selected folder, the macro loops through each file and does the following:
- Open an image.
- Duplicate the opened image.
- Run a plugin called Differentials JB with the operation set to Differ_X option - i.e. run(“Differentials JB”, “operation=DIFFER_X”);
- Resize the image - i.e. run(“Resize Canvas”, “width=240 height=240 position=Center zero”);
- Save the output image.
- Repeat steps 2-5 with plugin Differentials set to Differ_Y option - i.e. run(“Differentials JB”, “operation=DIFFER_Y”);
- Close all.
Issue/Problem: When I run the macro, the output images are not the same as what I get when I manually perform the steps (described above). On using the Debug macro option, I could identify the line that is causing the problem. It appears that when the macro runs the plugin (Differentials JB), it does not apply the operation setting as mentioned in the macro. The macro uses either the default or last used operation setting (i.e. if I opened ImageJ and then run the macro, the plugin Differentials JB uses the default operation setting instead of switching to operation=Differ_X setting as written in the macro. If I manually used Differentials JB with Differ_X operation setting, and then run the macro, the plugin Differentials JB uses operation=Differ_X setting for all the images processed by the macro).
I do not know how to rectify this problem. The line “run(“Differentials JB”, “operation=DIFFER_X”);” was obtained from the recorder macro option, so I do not believe the command is incorrect. I appreciate any help or advice on how to proceed from here. Thank you in advance.