Help with Java Code

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Help with Java Code

Rohitesh Gupta
Hi All,

I am new to java and doesn't really understand much about it. I am attaching herein java code for your reference that was generated after recording macro.

I particularly need help with two of these things:

1) Making ROI more flexible such that if there is a rectangular image then rectangular Roi covering the 95% of the image is selected. If there is circular image as in the case of agar plate, then Oval ROI covering 95% of the image can be selected.

2) Making redirect option more generic such that the grayscale image opened on imagej is selected in the redirect option.

Thanks a lot,
Rohitesh

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;

public class My_Plugin implements PlugIn {

        public void run(String arg) {
                ImagePlus imp = IJ.getImage();
                imp2 = imp.duplicate();
                //IJ.setTool("oval");
                imp.setRoi(new OvalRoi(203,34,172,377));
                imp.setRoi(new OvalRoi(40,34,335,377));
                imp.setRoi(new OvalRoi(40,34,374,377));
                imp.setRoi(new OvalRoi(40,34,374,389));
                IJ.setAutoThreshold(imp, "Default");
                Prefs.blackBackground = false;
                IJ.run(imp, "Convert to Mask", "");
                IJ.run("Close");
                IJ.run("Set Measurements...", "area mean integrated add redirect=colony.jpg decimal=3");
                IJ.run(imp, "Analyze Particles...", "  show=Outlines display exclude summarize");
        }

}

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html