import ij.*; import ij.gui.*; import java.awt.*; import ij.plugin.filter.PlugInFilter; import ij.process.*; /** Phase from RI * * Gets Amplitude-Phase from Real-Imaginary-Saturation. * * This example adapted by pf from tutorial plugins named * ColorInverter & StackAverage found with the tutorial at * http://www.fh-hagenberg.at/mtd/depot/imaging/imagej * */ public class PhaseFromRI_ implements PlugInFilter { protected ImagePlus imp; // defines an instance variable, protected means what? public int setup(String arg, ImagePlus imp) { if (arg.equals("about")) {showAbout(); return DONE;} this.imp=imp; return DOES_32+STACK_REQUIRED; // checks for stacked floats as input } public void run(ImageProcessor ip) { ImageStack stack=imp.getStack(); // sets up the image stack for access // get width, height and the region of interest int w = ip.getWidth(); int h = ip.getHeight(); int nslices = (int) stack.getSize(); // gets the number of stack slices int dimension = ip.getWidth()*ip.getHeight(); float[] pixels01 = (float[]) stack.getPixels(1); // gets the first slice pixel array float[] pixels02 = (float[]) stack.getPixels(2); // gets the 2nd slice pixel array float[] pixels03 = new float[dimension]; if (nslices>2) {pixels03 = (float[]) stack.getPixels(3);} double amplitude=0; double phase=0; int i; // IJ.showMessageWithCancel("testwindow","look out"); // create a new image with the same size and copy the pixels of the original image ImagePlus fpimage = NewImage.createFloatImage("Phase",w,h,1,NewImage.FILL_BLACK); ImageProcessor fp_ip = fpimage.getProcessor(); float[] apixels = (float[]) fp_ip.getPixels(); for (int j=0;j