Wrapping ImageJ Plugins

To “wrap” an ImageJ plugin means to effectively integrate it into the neurospy platform and its dataflow paradigm. To accomplish this you'll need to do three basic things.

  1. Import the source code into NetBeans
  2. Wrap the plugin with neurospy-friendly code
  3. Modify the original plugin source to fit your own microscopy goals

Import the Source Code

This is a reasonably straightforward task. First acquire the source code for the desired plugin found at the ImageJ homepage. Generally each plugin should be a single class file with at least one underscore (“_”) character included in the last name. One the source file is located you will now import it into the “Filters-ImageJ” module or a module of your own that depends on the “Filters-ImageJ” module.

Note: In NetBeans there is no simple way to import a .java file into the module. Instead you must copy and past the code into a NetBeans generated .java file and rewrite the correct import statements.

Wrap the Plugin

To wrap the plugin you must attach the ins and outs of the ImageJ plugin to the ins and outs of the neurospy dataflow graph. In other works you'll have to plug the ImageJ plugin into the image stream within neurospy. The easiest method is to copy the code from the example class called “ImageJPluginFilter.java” and simply substitute your ImageJ plugin class for the “filter” variable within the constructor.

However, there is a significant caveat here. Unfortunately ImageJ strongly types the image data. What this means is that there are multiple types of image data, the ImageProcessor class, which ImageJ can deal with (8-bit B&W, 8-bit RGB, 16-bit RGB, etc.) which are all encapsulated within ImageJ's propietary image container, the ImagePlus class. Currently the scope only outputs in 8-bit B&W therefore only ImageJ plugins that can deal with this format will be usuable. However, converting between the different types of data formats is possible by returning the ImageProcessor from the ImagePlus class' getProcessor() method. Then on the ImageProcessor there are numerous conversion methods (ie. convertToFloat()).

Modifying the Plugin Source

This is the most difficult portion of the process because each plugin must be modified in its own way. The only two methods that each ImageJ plugin exposes are the setup() and run() methods.

  • setup() is used initialize the image and set a name to it.
  • run() is used to process the image after it has been loaded in setup() or loaded.

The underlying problem is that each plugin implements each of these filters in their own way. Some filters pop up a GUI window for each round of processing, some reset their parameters on each call of run() and some only load image files through their own GUI dialog. So in order to make the plugin functional in a streaming image environment such as neurospy you'll need to persist parameter settings, prevent GUI windows from opening on every frame and be able to load up image programatically.


Personal Tools