Login  Register

Re: Filters Public API

Posted by kostas-2 on Jun 13, 2008; 2:19pm
URL: http://imagej.273.s1.nabble.com/Filters-Public-API-tp3695891p3695897.html

Hello,
A ok.
However I don't see a reason for this methods to be private, except if it is the willing of the author

Best Regards,
Kostas

Sami Badawi-2 wrote
Hi Kostas,

This is how I run unit tests for plugins that I have written in
ImageJ, without starting the GUI. I run them either from Eclipse,
NetBeans or from command line using Maven.

public ImageProcessor runPluginFilterOnImage(String fileName,
PlugInFilter plugInFilter, String arg) {
        Opener opener = new Opener();
        ImagePlus image = opener.openImage(fileName);
        ImageProcessor ip = image.getProcessor();
        plugInFilter.setup(arg, image);
        plugInFilter.run(ip);
        return ip;
}

This works if you have written the PlugInFilter. If you want to use
this method for other people's PlugInFilter, what ImageJ is doing is
just have the class loader load the PlugInFilter, by class name. You
can do the same.
PlugInFilter pif = (PlugInFilter) Class.forName("PlugInFilterName").
This should give you better thread safety.
It will only work with plugins that do not have a GUI part, so it
would not work FFTFilter, which has an input dialog.

-Sami Badawi
http://www.shapelogic.org