[ImageJ-devel] ImageJ2 library set up and referencing?

Johannes Schindelin Johannes.Schindelin at gmx.de
Wed Aug 6 04:39:12 CDT 2014


Hi Vera,

On Wed, 6 Aug 2014, Vera Andrejchenko wrote:

> I would like to ask if ImageJ2 can be used as a library for developing
> stand alone applications, (not only for plugins)?

Yes, the idea of ImageJ2 is to future-proof ImageJ for many more use
cases, including writing a new application.

For details, see http://imagej.net/ImageJ2#Features_of_ImageJ2

> What I would like to use it is:
> - reading, writing, accessing pixel values of multidimensional
> (multispectral) images,
> - FFT, histograms, using the Filters (as they are in the ImageJ app)
> - Addition, multiplication etc. of image pixel values as they are in the
> Image Calculator methods (add, divide, multiply...)

It sounds as if you would benefit from the modular structure of ImageJ2:
you can basically cherry-pick which parts you want to use. In particular,
it looks as if you could benefit from ImageJ OPS -- which is still in the
hot phase of development. To get an idea how to make use of ImageJ OPS,
please have a look here: https://github.com/imagej/imagej-ops (scroll down
to the README)

> What I tried so far is using the .jars from the ImageJ.app and referenced
> them as external libraries from my project. But on the very beginning when
> I try creating the ImageJ object I keep receiving error messages related
> to some of the Services, for example:
> 
>  java.lang.UnsupportedOperationException: Cannot instantiate more than one
> DefaultLegacyService at net.imagej [...]

The problem you face is caused by *more* than one ImageJ object being
instantiated: every ImageJ object (which we call "gateway" because it is
basically a gateway to all the different services) is connected to a
"SciJava context" that basically offers all the services such as the
plugin service, the event service, the log service, etc

Due to limitations in ImageJ 1.x' design, the legacy service --
responsible for executing any function in ImageJ 1.x -- can be
instantiated only once per class loader. That means that you have to
*dispose* of a SciJava context offering a legacy service *before* you can
instantiate a new context.

> So I was wondering if I can use ImageJ2 as an image processing library
> for my proejct...

Absolutely.

> If it is meant to be used as an image processing library which can be
> referenced from other projects? If yes, could you send me some links I can
> read how to properly set it up and reference the necessary libraries?

The best examples we have live in this source code repository:

	https://github.com/imagej/imagej-tutorials/

I would like to point you in particular to 'load-and-display-dataset' and
'using-ops'.

Ciao,
Johannes



More information about the ImageJ-devel mailing list