[ImageJ-devel] Questions about imglib2
Stephan Preibisch
preibisch at mpi-cbg.de
Thu Mar 15 07:09:43 CDT 2012
Hi Brian,
for now a simple way to save an Img (if it is 1-5d and RealType) is to wrap/copy it to an ImageJ ImagePlus and then use the ImageJ tools for saving, e.g.:
ImagePlus imp = ImageJFunctions.copyToImagePlus( img );
But it will only be saving as UnsignedByte, UnsignedShort or Float .... i.e. the types that ImageJ supports.
Nice greetings,
Stephan
On Mar 15, 2012, at 7:05 , Stephan Saalfeld wrote:
> 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
>
>
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
More information about the ImageJ-devel
mailing list