【问题标题】:IJ.close() - Scripting python in ImageJ/FIJIIJ.close() - 在 ImageJ/FIJI 中编写 python 脚本
【发布时间】:2014-12-18 12:21:13
【问题描述】:

我对 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'

知道如何解决这个问题吗?

谢谢!

【问题讨论】:

    标签: python jython imagej


    【解决方案1】:

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

    尝试类似:

    IJ.open(i)
    imp = IJ.getImage()
    imp.getProcessor().setf(100, 100, 3.14159) # or whatever
    IJ.save(imp, "/path/to/myShinyModifiedImage.tif")
    imp.close()
    

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

    另请注意,Jython 语句的结尾没有分号。

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2018-08-13
        • 1970-01-01
        • 2021-07-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多