简体   繁体   中英

ImageJ silent mode - process without opening images

I need to run Macro, but I don't want to show the image. If I don't call the imp.show(), ImageJ will print to the console There are no images open. So how can I run Macro without showing the image? Thanks in advance.

public class MyPlugin implements PlugIn {

public static void MyPlugin(String path) {
    System.setProperty("plugins.dir", "libraries/plugins");
    System.setProperty("macros.dir", "libraries/macros");
    Opener opener = new Opener();
    ImagePlus imp = opener.openImage(path);
    imp.show();
    IJ.run(imp, "Skeletonize", "");
    runMacroFile("libraries/macros/FindJunctions", "");
    imp.close(); 
}
  • If you make your macro an ImageJ command by putting the file into any subfolder of plugins/ (eg plugins/macros/Find_Junctions.ijm , see the ImageJ documentation ), you should be able to run:

    IJ.run(imp, "Find Junctions", "");

    where imp is your current image. However, this doesn't prevent commands within the macro to display images, unless the macro itself sets setBatchMode(true) .

  • A safer way to avoid displaying images is to avoid calling the macro at all, and to include all commands of the macro into your plugin. You can get the required command syntax by running the macro recorder in Plugin mode.

Since your code example doesn't compile, and you don't supply any details about the macro you want to call, I can't help you much further.

Add setBatchMode(true); to the beginning of your macro. See built-in macro functions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM