How to connect ImageJ to python?

前端 未结 4 1238
误落风尘
误落风尘 2020-12-15 14:11

I am using Python to design a software, and the image processing is one of the steps. I am using ImageJ to realize this.

Since there is a Jython interpreter within I

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 14:37

    There is this https://github.com/imagej/imagej.py module which provides an integration between Python and 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) 
    

提交回复
热议问题