gpt4 book ai didi

java - 将 ImageJ 宏命令实现到现有插件中

转载 作者:行者123 更新时间:2023-11-30 08:13:27 25 4
gpt4 key购买 nike

我正在尝试更改现有插件 OpenComet对于 ImageJ。我不喜欢 Java,所以也许这是一个简单的任务。

我正在尝试实现以下内容

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

  2. run("水平翻转");

这应该放入以下代码中:

// 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 的类或类似的东西。我不会吗?

提前非常感谢。

最佳答案

  1. run("Bio-Formats Windowless Importer", "open=path autoscale
    color_mode=Default view=Hyperstack stack_order=XYCZT");

    opening my files with the help of the Bioformat Importer plugin

您可以使用生物格式的 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");

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

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

如果你想了解较低级别的Java命令,请使用Command Finder (按 [L] 或插件 > 实用程序 > 查找命令...)并输入“flip”,您将找到实现该命令的类:

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

希望有帮助。

关于java - 将 ImageJ 宏命令实现到现有插件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30015440/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com