I have been playing around with using ImageJ/Fiji as a GUI for a python script.
Using pyimageJ - I can open an ImageJ instance
import imagej ij = imagej.init('C:\Fiji.app', headless=False) ij.ui().showUI() #This opens an Fiji window complete with all installed Plugins, which is pretty handy. #Any image opened in Fiji can be imported into memory for your python script by using jnius to call the java class using this: from jnius import autoclass WindowManager = autoclass('ij.WindowManager') imp = WindowManager.getCurrentImage() #and you can visualize the imported image with: ij.py.show(imp, cmap = 'gray') If I try to convert to a numpy array using import numpy as np img = np.array(imp, 'float')
I cannot assign a dtype and I get an error
[TypeError: float() argument must be a string or a number, not ‘ij.ImagePlus’]
And, if I try to visualize the image with matplotlib imshow
import matplotlib as plt plt.imshow(img)
I get this error: [TypeError: Image data can not convert to float]
Has anyone converted an ImagePlus obj. to a numpy array?
I tried looking at other ImageJ classes for conversion but I can’t find anything.
I know I can just read files directly into Python with various readers but I would really like to go back and forth from python to ImageJ to take advantage of all the plugins available.
Thanks for everyone’s time in looking at this, and providing any ideas, pointers.