问题描述
我正在使用Python设计软件,图像处理是步骤之一.我正在使用ImageJ来实现这一点.
I am using Python to design a software, and the image processing is one of the steps. I am using ImageJ to realize this.
由于ImageJ中有一个Jython解释器,可以在ImageJ软件中打开它,因此必须有一种将ImageJ连接到Python并调用Python中所有函数的方法.
Since there is a Jython interpreter within ImageJ, which can be opened within ImageJ software, there must be a way to connect ImageJ to Python and call all the functions within Python.
我想知道如何才能完成Python中的所有处理,而不是在ImageJ中打开解释器吗?
I wonder how I can do that to finish all the processing in Python rather than open the interpreter in ImageJ?
推荐答案
有这个 https://github.com/imagej/imagej.py 模块,该模块提供了Python和ImageJ之间的集成.
There is this https://github.com/imagej/imagej.py module which provides an integration between Python and ImageJ.
有了它,您可以轻松地在Python中使用ImageJ.这是一个示例脚本:
With it you can easily use ImageJ in Python. Here is a sample script:
# Spin up ImageJ.
import imagej
ij = imagej.init('/Applications/Fiji.app')
# Import an image with scikit-image.
import skimage
from skimage import io
# NB: Blood vessel image from: https://www.fi.edu/heart/blood-vessels
img = io.imread('https://www.fi.edu/sites/fi.live.franklinds.webair.com/files/styles/featured_large/public/General_EduRes_Heart_BloodVessels_0.jpg')
import numpy as np
img = np.mean(img, axis=2)
# Invoke ImageJ's Frangi vesselness op.
vessels = np.zeros(img.shape, dtype=img.dtype)
import imglyb
ij.op().filter().frangiVesselness(imglyb.to_imglib(vessels), imglyb.to_imglib(img), [1, 1], 20)
这篇关于如何将ImageJ连接到python?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!