ImageJ plugins

I’ve started building a new plugin system for ImageJ which will be much easier to work with.

Just to review, the current plugin system uses two interfaces (ij.plugin.PlugIn and ij.plugin.PlugInFilter) to implement these. The second is meant for implementing image processing algorithms. It defines two functions:

int setup(String cmd, ImagePlus imp)
All the setup work for the plugin is supposed to be done here. All parameters are passed through cmd, which is a holdover from ImageJ’s reprehensible macro language. The actual image to process is passed through imp.
void run(ImageProcessor ip)
After ImageJ has called the setup function, it calls run for each element of the image stack. ImageProcessors hold the actual pixel data for each image in the stack, which is wrapped up in the ImagePlus.

Note several obvious problems:

  • Plugins receive all their parameters from a string, so you have to write a mini-parser for each plugin. Everyone writes different parsers.
  • The ij.plugin.filter.PlugInFilter interface insists that setup returns an int (telling the plugin’s capabilities, which is reasonable), and run returns a void. How do you get the new image back?
  • If you expect to run the plugin from a menu instead of the macro language or directly from Java, you have to write an interface to get parameters from the user. Then you have to make it not appear when you’re called from the other two contexts.

A fix should automatically support all three contexts (Java, the macro language, and menus), without any additional programmer effort. This is impossible, but we can get fairly close, as I’ll describe next.

One Comment

  1. Physicist Amok » Blog Archive » ImageJ plugins 2:

    […] (This is a followup to ImageJ plugins) […]

Leave a comment