Created
January 9, 2018 04:52
-
-
Save GenevieveBuckley/460d0abc7c1b13eee983187b955330ba to your computer and use it in GitHub Desktop.
ImageJ API scripting in Jython - how to convert to and from ImgPlus and ImagePlus. http://javadoc.scijava.org
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Converting from ImagePlus to ImgPlus. | |
When an ImagePlus is made available by ImageJ 1.x, | |
you can pass it to ImgLib2 as an Img via ImageJFunctions.wrap(imp) | |
http://javadoc.scijava.org/ImgLib2/net/imglib2/img/display/imagej/ImageJFunctions.html | |
""" | |
from ij import IJ | |
from net.imglib2.img import ImagePlusAdapter | |
image = IJ.openImage() # opens a file picker, or you can add the filename string as an argument. | |
output = ImagePlusAdapter.wrapImgPlus(image) # | |
output.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Wrap any Img as an ImgPlus.""" | |
from net.imagej import ImgPlus | |
imgplus = ImgPlus(img) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @Dataset img | |
"""Converting from ImagePlus to ImgPlus. | |
When an ImgLib2 RandomAccessibleInterval needs to be passed to ImageJ 1.x, it can be wrapped into an ImagePlus via ImageJFunctions.wrap(img, title). | |
""" | |
from net.imglib2.img.display.imagej import ImageJFunctions | |
output = ImageJFunctions.wrap(img, "title") # wraps the ImgPlus as an ImagePlus | |
output.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment