Closed lizhogn closed 3 years ago
I have the same issue. Did you find any solution for that?
I have the same issue. Did you find any solution for that?
No,I just give up😅
I have the same issue. Did you find any solution for that?
No,I just give up😅
Look into porespy.imagej function. It may solve your problem.
I have the same issue. Did you find any solution for that?
No,I just give up😅
Look into porespy.imagej function. It may solve your problem.
OK,thanks.
@lizhogn Since your post we've moved pyimagej's java bridge from pyjnius to JPype so the syntax is a little different if you have revisited pyimagej since your question. Instead of using ij.py.to_java(numpy_colony)
you should use ij.py.to_dataset
instead. The to_java
method sends the numpy array to java land and returns the java equivalent of the array. Note that the to_java
method is more generic and will also take numbers, lists and other objects and convert them to java objects. The to_dataset
however returns an imagej dataset which is a wrapper for the ImgPlus
object
import imagej
from skimage import io
# initialize imagej
ij = imagej.init('sc.fiji:fiji')
# load image
numpy_colony = io.imread('Cell_Colony.jpg') # type: numpy.ndarray
java_colony = ij.py.to_dataset('numpy_colony) # type: net.imagej.DefaultDataset
# run macro
ij.py.run_macro("""run("Convert to Mask");""")
Alternatively, if you open your imagej with Imagej's opener instead of skimage
you'll get a net.imagej.DefaultDataset
object.
image = ij.io().open('Cell_Colony.jpg') # returns net.imagej.DefaultDataset
In my use I'll use to_dataset
to convert images to net.imagej.DefaultDataset
objects when the imagej is coming from some other python source that I don't have much control over. If I'm loading images from my local disk I'll just use ij.io().open()
.
@lizhogn Since your post we've moved pyimagej's java bridge from pyjnius to JPype so the syntax is a little different if you have revisited pyimagej since your question. Instead of using
ij.py.to_java(numpy_colony)
you should useij.py.to_dataset
instead. Theto_java
method sends the numpy array to java land and returns the java equivalent of the array. Note that theto_java
method is more generic and will also take numbers, lists and other objects and convert them to java objects. Theto_dataset
however returns an imagej dataset which is a wrapper for theImgPlus
objectimport imagej from skimage import io # initialize imagej ij = imagej.init('sc.fiji:fiji') # load image numpy_colony = io.imread('Cell_Colony.jpg') # type: numpy.ndarray java_colony = ij.py.to_dataset('numpy_colony) # type: net.imagej.DefaultDataset # run macro ij.py.run_macro("""run("Convert to Mask");""")
Alternatively, if you open your imagej with Imagej's opener instead of
skimage
you'll get anet.imagej.DefaultDataset
object.image = ij.io().open('Cell_Colony.jpg') # returns net.imagej.DefaultDataset
In my use I'll use
to_dataset
to convert images tonet.imagej.DefaultDataset
objects when the imagej is coming from some other python source that I don't have much control over. If I'm loading images from my local disk I'll just useij.io().open()
.
That's great, thank you very much
In ImageJ with Python Kernel, there is a example about Running a plugin:
if I want to process the numpy array by imagej macro like this:
If I don't do something in the <<<>>>, it will say "There are no images open." I think there is a function which can tranlate the java_colony array into a ImagePlus object.