IJ.close() - 在ImageJ / FIJI中编写脚本

时间:2014-12-18 12:21:13

标签: python jython imagej

我特别陌生的python /脚本,我遇到了问题。我在斐济写了以下内容(脚本的缩写版本在下面......)

from ij import IJ, ImagePlus
from java.lang import Runtime, Runnable

import os

filepaths = []

for folder, subs, files in os.walk('location/of/files/'):
    for filename in files:
        #the next part stops it appending DS files
        if not filename.startswith('.'):
            filepaths.append(os.path.abspath(os.path.join(folder, filename,)))   

for i in filepaths:
    IJ.open(i);
    IJ.close();

基本上我想打开图像,做东西,然后使用IJ.close()关闭处理过的图像。但是它会出现以下错误:

AttributeError: type object 'ij.IJ' has no attribute 'close'

知道怎么解决这个问题吗?

谢谢!

2 个答案:

答案 0 :(得分:0)

IJ类没有close()方法。您可能想要调用close()的{​​{1}}方法,这是图像对象本身的类。

尝试类似:

ImagePlus

如果您需要操作多平面图像的多个切片,请参阅“切片切片”模板(Script Editor的模板> Python菜单)。

另请注意,Jython在语句上没有尾随分号。

答案 1 :(得分:0)

对于使用 jython(ImageJ/Fiji 中的 python)编写脚本的任何其他人,Java 文档总是有助于获得模块及其类/函数的概述: Here for example for the module ij