IJ.close()-在ImageJ/FIJI中编写python脚本 [英] IJ.close() - Scripting python in ImageJ/FIJI

查看:238
本文介绍了IJ.close()-在ImageJ/FIJI中编写python脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是python/scripting的新手,遇到了问题.我在斐济写了以下内容(脚本的缩短版本在下面...)

I'm exceptionally new to python/scripting and I'm having a problem. I'm writing the following in Fiji (shortened version of the script is below...)

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()关闭处理后的图像.但是,它给出了以下错误:

Basically I want to open an image, do stuff, and then close the processed image using IJ.close(). However it gives the following error:

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

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

Any idea how to get around this?

谢谢!

推荐答案

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

The IJ class does not have a close() method. You probably want to call the close() method of ImagePlus, which is the class for the image objects themselves.

尝试类似的东西:

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

如果需要对多平面图像的多个切片进行操作,另请参见切片上方的循环"模板("Python"菜单="nofollow">脚本编辑器).

If you need to operate over multiple slices of a multi-plane image, see also the "Loop over slices" template (Templates > Python menu of the Script Editor).

还请注意,Jython在语句中没有结尾的分号.

Note also that Jython does not have trailing semicolons on statements.

这篇关于IJ.close()-在ImageJ/FIJI中编写python脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆