ImageJ:打开一系列文本图像作为堆栈

ImageJ: Open a series of text images as a stack

在 ImageJ 中,我可以使用文件>>导入>>图像序列打开一系列图像(tif、png、jpg 等)作为堆栈...

我可以使用文件>>导入>>文本图像打开文本图像(包含像素矩阵的 .txt 文件)...

但是我怎样才能将一系列文本图像作为堆栈打开?

有些人提供了一个 Macro 来执行此操作,但效果不是很好,因为它还会单独打开所有图像,如果您打开了其他图像,那么这些图像会合并到堆栈也是如此(连续两次尝试 运行 宏)。

如果有一个宏或插件可以将文本图像导入单个堆栈(忽略其他打开的图像)而不调出单个图像,那就太好了。基本上,它应该像 Import>>Image Sequence 一样操作。

这是作为起点的当前宏,但我不确定这是最好的起点。谢谢!

dir = getDirectory("Choose directory");
list = getFileList(dir);
run("Close All");
setBatchMode(true);
for (i=0; i<list.length; i++) {
   file = dir + list[i];
   run("Text Image... ", "open=&file");
}
run("Images to Stack", "use");
setBatchMode(false);

就个人而言,您粘贴的宏在最近的斐济 运行 时对我有用 - run("Close All"); 行旨在防止意外图像被包含在您的堆栈中,而批处理模式可防止间歇性的图像弹出。

事实上,如果您尝试 运行 使用非 2D 图像(即您之前 运行 的输出),Images to Stack 应该会抱怨。因此,如果您在 运行 启用宏时看到此行为,这可能是一个错误 - 您能否提供有关您使用的 ImageJ/OS/Java 版本的更多信息?

此外,更通用的解决方案可能是 Bio-Formats importer - which has a flag that allows you to group multiple files into a single stack. If you don't want to manually install it, Bio-Formats is included by default with the Fiji distribution of ImageJ

您可能还对测试 ImageJ2 功能感兴趣,该功能旨在将完整格式支持插入现有功能 - 例如这样像这样的宏就不需要针对个别格式进行定制。理论上,如果您下载 Fiji 并打开 Edit>Options>ImageJ2,那么 File>>Import>>Image Sequence... 应该会按照您希望的方式工作...但目前尚未经过充分测试。

如果想避免关闭其他打开的图片,可以使用Images to StackTitle Contains参数:

只需重命名打开的文本图像,使其标题包含唯一的字符串。 使用Macro recorder得到对应的宏代码:

dir = getDirectory("Choose directory");
list = getFileList(dir);

setBatchMode(true);
for (i=0; i<list.length; i++) {
    file = dir + list[i];
    run("Text Image... ", "open=[" + file + "]");
    rename("myUniqueIdentifier" + file);
}
run("Images to Stack", "title=myUniqueIdentifier");
setBatchMode(false);