As we said before, the PlugInFilter
interface is the one you need to implement if you want to code a plugin that performs operations on an image that is already open (similar to what macros do). This interface provides an extra method (setup
) for you to implement that checks whether the image to be acted upon is of the type expected by the plugin and then proceeds to execute the run
method. The following plugin offers an example and will also serve to explain additional functions:
import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.filter.*; public class Example_Filter_Plugin implements PlugInFilter { ImagePlus imp; public int setup(String arg, ImagePlus imp) { boolean wrong_version = IJ.versionLessThan("1.46r"); if (wrong_version) return DONE; this.imp = imp; return DOES_8G; } public void run(ImageProcessor ip) { IJ.showStatus("Start processing..."); IJ.wait(2000...