简体   繁体   English

ImageJ静默模式-处理过程无需打开图像

[英]ImageJ silent mode - process without opening images

I need to run Macro, but I don't want to show the image. 我需要运行Macro,但是我不想显示图像。 If I don't call the imp.show(), ImageJ will print to the console There are no images open. 如果我不调用imp.show(),则ImageJ将打印到控制台没有打开的图像。 So how can I run Macro without showing the image? 那么如何在不显示图像的情况下运行Macro? 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: 如果通过将文件放入plugins/任何子文件夹(例如, plugins/macros/Find_Junctions.ijm ,请参见ImageJ文档 )将宏作为ImageJ命令 ,则应该能够运行:

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

    where imp is your current image. 其中imp是您当前的图像。 However, this doesn't prevent commands within the macro to display images, unless the macro itself sets setBatchMode(true) . 但是,这不会阻止宏中的命令显示图像,除非宏本身设置了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); 添加setBatchMode(true); to the beginning of your macro. 到宏的开头 See built-in macro functions . 请参阅内置宏功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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