import ij.*; import ij.gui.*; import java.awt.*; import ij.plugin.*; import ij.plugin.filter.PlugInFilter; import ij.process.*; /** digital darkfield Tableau * * Converts a real imaginary fourier stack into a * tiled array of darkfield (and one brightfield) images. * * 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 ddfTableaux_ implements PlugInFilter { // , PlugIn protected ImagePlus imp; // defines an instance variable, protected means what? static double wrad = 32; static boolean normalized = true; 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) { //line30 // if (!IJ.showMessageWithCancel("Warning","Are you ready to over write the selected image?")) return; if (!showDialog()) return; 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 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 //line40 // create a scratch image with the same size ImagePlus oImage = NewImage.createFloatImage("Digital Darkfield Tableau",w,h,2,NewImage.FILL_BLACK); ImageStack oStack = oImage.getStack(); // oStack.ConvertToGray32(); float[] pixels01o = (float[]) oStack.getPixels(1); float[] pixels02o = (float[]) oStack.getPixels(2); // now calculate offsets from dialog inputs // int xoff = (int) (roff*Math.cos(aoff*Math.PI/180.)); // int yoff = (int) (roff*Math.sin(aoff*Math.PI/180.)); // // Rectangle roi01; int xnew, ynew; int oldj, newj; int roix=0, roiy=0, roiw=(int) wrad, roih=(int) wrad; // later prompt for roiw/roih int nxwin, nywin; nxwin = w/roiw; nywin = h/roih; // nxwin = 1; nywin = 1; // debug statement String s = imp.getTitle(); for (int y = 0; y < h; y++){ // load old image into the scratch image space for (int x = 0; x < w; x++){ oldj = x + w*y; pixels01o[oldj]=pixels01[oldj]; pixels02o[oldj]=pixels02[oldj]; } } int k, kroi, newx, newy; float scale=1; double mag; Rectangle fitRect = new Rectangle(); fitRect.x = 0; fitRect.y=0; fitRect.width = roiw; fitRect.height = roih; ImageStack stackin = new ImageStack(roiw,roih); float[] rein = new float[roiw*roih]; float[] imin = new float[roiw*roih]; stackin.addSlice("Real", rein); stackin.addSlice("Imaginary", imin); float[] inrepix = (float[]) stackin.getPixels(1); float[] inimpix = (float[]) stackin.getPixels(2); ImageStack stackout = new ImageStack(roiw,roih); float[] reout = new float[roiw*roih]; float[] imout = new float[roiw*roih]; stackout.addSlice("Real", reout); stackout.addSlice("Imaginary", imout); float[] outrepix = (float[]) stackout.getPixels(1); float[] outimpix = (float[]) stackout.getPixels(2); int offset = roiw/2; for (int iw = 0; iw