ImageJ-如何从图像堆栈中的实际处理图像中获取切片名称

时间:2016-03-16 09:58:34

标签: java image-processing imagej

我在ImageJ的图像堆栈中获取文件名时遇到问题。 我写了一个可以在图像堆栈上使用的插件,并为堆栈中的每个图像提供输出结果:

if (mfpc == true) {
            IJ.log(fileName+": Good");
        } else {
            IJ.log(fileName+": Bad");
        }

getTitle()适用于单个图像,但仅显示堆栈的堆栈名称,而不是实际切片的名称。

我还尝试使用以下代码获取切片名称

fileName = imp.getImageStack().getShortSliceLabel(imp.getCurrentSlice());

但它只显示当前选择的图片,而不是插件处理的图片。我的一厢情愿是以下输出(文件名为Imagex.png):

  • Image1.png:好
  • Image2.png:错误
  • Image3.png:好

这可能,如果可能,怎么样? :)

2 个答案:

答案 0 :(得分:0)

解决问题的一种肮脏方法:运行Stack to Images,存储数组中的所有名称,关闭所有图像,再次打开堆栈。

以下是ImageJ宏语言中的代码段:

setBatchMode(true);

open("your_stack.tif")

n=nSlices;
titles=newArray(n);

run("Stack to Images");

// for every image (slice of the stack)
for(cpt=0;cpt<n;cpt++){
    titles[cpt]=getTitle(); //get its title
    close(); //then close it so focus goes to the next image
}

Array.print(titles);

答案 1 :(得分:0)

您可以使用命令getInfo("slice.label");

获取切片名称。