[ImageJ-devel] Questions about imglib2
Stephan Saalfeld
saalfeld at mpi-cbg.de
Thu Mar 15 06:05:20 CDT 2012
Hi Brian,
> 1) How do I convert an net.imglib2.img.Img to a
> java.awt.image.BufferedImage?
>
There is the interface ScreenImage which can return a BufferedImage
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/ScreenImage.java
implemented by ARGBScreenImage
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/ARGBScreenImage.java
and UnsignedByteScreenImage
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/UnsignedByteScreenImage.java
. Both are Img themselves, so writing into their pixels changes the
content of the BufferedImage. You can also map an arbitrary XY-plane of
a RandomAccessibleInterval (Img is one) into such a screen image using
either of the two Projectors:
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/XYProjector.java
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/XYRandomAccessibleProjector.java
which includes type conversion from your source type into either ARGB or
UnsignedByte using a Converter
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/converter/Converter.java
Default implementations are available, e.g.
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/core/src/main/java/net/imglib2/display/RealARGBConverter.java
An example how to use it together with ImageJ is here:
http://fiji.sc/cgi-bin/gitweb.cgi?p=imglib.git;a=blob;f=imglib2/tests/src/test/java/tests/OpenAndDisplayScreenImage.java;h=77a9dcffee790f6d202c3c730e7588b203a2def2;hb=HEAD
> 2) How do I write a net.imglib2.img.Img to disk as the usual formats
> (jpg, png, tiff) ? You have an ImgOpener but no ImgCloser err, I mean
> ImgWriter.
>
Mark Hiner and Curtis Rueden are working on an ImageSaver:
https://github.com/ctrueden/bioformats/blob/imglib-io/components/scifio/src/ome/scifio/img/ImgSaver.java
Until this is finished, you will have to write data otherwise.
Best,
Stephan
More information about the ImageJ-devel
mailing list