A sample plugin
We will start digging into this topic by analyzing the following plugin code. That will give us a nice starting point to introduce the different aspects for developing ImageJ plugins:
import ij.*; import ij.process.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; import ij.plugin.frame.*; public class Test_Plugin implements PlugIn { public void run(String arg) { int width = 300; int height = 300; ImageProcessor ip = new ByteProcessor(width, height); ip.setColor(Color.black); ip.fill(); for(int x = 0; x < width; x++) { for(int y = 0; y < height; y++) { if (x == y || (width - x) == y) ip.putPixel(x, y, 255); } } ImagePlus imp = new ImagePlus("Result image", ip); imp.show(); } }
First things first: this is a plugin, and not a macro. To edit it, navigate to Plugins | New | Plugin. A sample skeleton will be opened and you just need to fill in the run(arg...