【问题标题】:Implementing ImageJ macro commands into an existing Plugin将 ImageJ 宏命令实现到现有插件中
【发布时间】:2015-05-03 15:12:16
【问题描述】:

我正在尝试更改 ImageJ 的现有插件 OpenComet。我不喜欢 Java,所以也许这很容易。

我想要实现的是以下几点

  1. run("Bio-Formats Windowless Importer", "open=path autoscale color_mode=Default view=Hyperstack stack_order=XYCZT");
    在 Bioformat Importer 插件的帮助下打开我的文件

  2. run("Flip Horizontally");

这应该放在下面的代码中:

// Iterate over each input file
            for(int i=0;i<inFiles.length;i++){
                // Try to open file as image
//NUMBER 1 BIOFORMAT IMPORT AT THIS POINT               
                ImagePlus imp = IJ.openImage(inFiles[i].getPath());
                                // If image could be opened, run comet analysis
                if(imp!=null){
//NUMBER 2 FLIPPING AT THIS POINT
                    String imageKey =  inFiles[i].getName();

此外,我需要导入 BioFormat Importer 的类或类似的东西。我不会吗?

非常感谢。

【问题讨论】:

    标签: java plugins imagej


    【解决方案1】:
    1. run("Bio-Formats Windowless Importer", "open=path autoscale color_mode=Default view=Hyperstack stack_order=XYCZT");

      在 Bioformat Importer 插件的帮助下打开我的文件

    您可以使用生物格式的BF 辅助类来实现这一点(参见它的API documentation)。有关 javascript 示例,请查看 here。在 Java 中,这可能看起来像:

    import loci.plugins.BF;
      [...]
    ImagePlus[] imps = BF.openImagePlus(inFiles[i].getPath());
    ImagePlus imp = imps[0];
    
    1. run("Flip Horizontally");

    Java模式下使用recorder插件>宏>记录...)获取所需的命令:

    import ij.IJ;
     [...]
    IJ.run(imp, "Flip Horizontally", "");
    

    如果您想了解较低级别的 Java 命令,请使用 Command Finder(按 [L] 或 Plugins > Utilities > Find Commands...)并输入“flip”并你会找到实现命令的类:

    ij.plugin.filter.Transformer("fliph")
    

    希望对您有所帮助。

    【讨论】:

    • 感谢您的详细解释,但我仍然无法打开文件。它不工作。
    • 您能否详细说明如何它“不工作”?例如,通过提供MCVE 以及您收到的错误消息?
    • 抱歉,没有什么可详细说明的……只是什么也没发生。但是现在这样它可以工作了,我不知道它是否有意义......:'importClass(Packages.loci.plugins.BF); var imps = BF.openImagePlus(路径); ImagePlus imp = BF.openImagePlus(inFiles[i].getPath()); imps[0].show();'但是翻转根本不起作用,只是没有任何反应该命令被完全忽略
    • 小心,您在这里混合了 Java 和 Javascript。 inFiles[i].getPath()的内容是什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多