How to use PlugInFilterRunner


#1

Hi,

I would like to start a plugin which is not visible in ImageJ (not added to plugins.config) with the PlugInFilterRunner, because it parallelize nicely for stacks (my own implementation needs much more memory…). I’m not sure how to use that class. I was curious if there is any experience how to use it.

Best,
Thorsten


#2

Let me extend the question: At the moment, I tried to parallelize the processing of a stack by creating an ExecuteService with a fixed number threads (= number of cores) and then add a “Worker”-Thread (class that extends the Thread class) for each image in the stack to to executor service. If I implement the stuff from the worker-thread-class as a PlugInFiler it parallelizes perfectly and needs only fraction of memory.

Therefore I was wondering how the PlugInFilter parallelization works. I take a look into the PlugInFilterRunner class:

From that piece of code I guess it works as follows:
Lets say we have 8 cores and a stack of 24 image. The PlugInFilterRunner would create 8 threads where each thread processes 3 images. Right? As it is imagej1, maybe @Wayne could tell me if I’m right?


#3

I’ve implemented my stuff as described here:

Lets say we have 8 cores and a stack of 24 image. The PlugInFilterRunner would create 8 threads where each thread processes 3 images.

The memory problem is gone. However, I’m still interested in how the PluginFilterRunner can be used so I will not mark my thread as solved.


#4

I don’t understand why you want to absolutely use PlugInFilterRunner. In its javadoc, it says:

So the intended use would be to create e.g. an ExtendedPlugInFilter and that implements PlugInFilterRunner to generate a preview in its showDialog method.


If you simply want to call a Runnable on a separate thread, I think you should use the SciJava ThreadService.


#5

Hi All,
I am trying to invoke the dialog window (including the preview option) of BackgroundSubtracter() within a script using JavaScript. I searched for help about how to setup the PlugInFilterRunner required by showDialog(), but I couldn’t find any (or - better - couldn’t understand it, 'cause I’m an ignorant beginner…).
This is an example of how I setup the BackgroundSubtracter() in JavaScript:

imp = IJ.openImage("http://imagej.nih.gov/ij/images/gel.gif");
ip = imp.getProcessor();
bk = new BackgroundSubtracter();
bk.setup("",imp);
// bk.showDialog(imp, "", PlugInFilterRunner);
bk.rollingBallBackground(ip, 28, false, true, true, false, false);
imp.show();

I would really appreciate any help or example about how to handle this in JS, Python or any other way! Thank you very much in advance!

Best,
Fabio


#6

Is there any reason why you don’t simply call IJ.run with the command name?

For example in Javascript:

importClass(Packages.ij.IJ);
IJ.open("http://imagej.nih.gov/ij/images/gel.gif");
IJ.run("Subtract Background...");

#7

Yes, because I would like to grab using genericDialog() via the commands

getNextBoolean();
getNextNumber();

the final set of values that I feed to the rolling ball filter after previewing the results.
I tried to invoke the macro recorder before running the filter, in this way:

        IJ.run("Record...","");
        IJ.run("Subtract background...","");

but I don’t get the final set of parameters that I enter to the dialog window, and I read that it is not possible to get it that way.
Invoking the BackgroundSubtracter() is the only other idea I got, but if there is an easier alternative I would be very glad!