[ImageJ-devel] Simple usage of ImageJ2 and ImgLib2

Padraig Looney padraig.looney at gmail.com
Mon Jul 16 03:13:19 CDT 2012


Dear list,

Apologies if this posting is not in the correct place but I seem to have
hit a brick wall in moving to ImgLib2 and ImageJ2.

I have used ImageJ 1 without the the user interface for a variety of
software projects. In Image J to open an Image I would use

Opener opener = new opener();
Imageplus imp = opener.openImage("someFile");
imp.show();

and from there I could perform the processing and change the display etc.

With a view to moving to imgLib2 and ImageJ2 I have been going through the
Javadoc to try to display an image perform more complicated tasks. So I
have found this example among others on the Imglib2 site but in the imgLibs
package there is no ImageJFunctions anymore.

public < T extends RealType< T > & NativeType< T > > Example1b()
        throws ImgIOException, IncompatibleTypeException
    {
        // define the file to open
        File file = new File( "DrosophilaWing.tif" );

        // open with ImgOpener using an ArrayImgFactory, here the return
type will be
        // defined by the opener
        // the opener will ignore the Type of the ArrayImgFactory
        ImgFactory< ? > imgFactory = new ArrayImgFactory< T >();
        Img< T > image = new ImgOpener().openImg( file.getAbsolutePath(),
imgFactory );

        // display it via ImgLib using ImageJ
        ImageJFunctions.show( image );

        // open with ImgOpener as Float using a CellImgFactory, it will be
opened as float
        // independent of the type of the image
        // to enforce to open it as FloatType, an instance of FloatType has
to be passed along
        Img< FloatType > imageFloat = new ImgOpener().openImg(
file.getAbsolutePath(),
            new CellImgFactory< FloatType >( 10 ), new FloatType() );

        // display it via ImgLib using ImageJ
        ImageJFunctions.show( imageFloat );
    }

Ideally I would like to use Swing and get a Canvas containing the image and
to be able to put this on a JFrame. I have gone through the ImageJ2 javadoc
and I have found a range of classes that seem relevant such as
Defaultdataset, SwingSdiImageDisplayViewer, SwingDisplayPanel but I keep
running into errors with Services that don't exist because I am probably
not using ImageJ2 as intended.

Many thanks

Padraig Looney
Medical Physicist
Royal Surrey County Hospital
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20120716/16729a2e/attachment.html>


More information about the ImageJ-devel mailing list