Help with Java Code

Hi All,

I recorded a java code to perform colony counting using imagej. Now, I am interested in making this code more generic such that i don’t have to rerun the steps on imagej but just put in this code for direct assessment. I need help with two 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.
    Here is the java code for reference:
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();
		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;, "Convert to Mask", "");"Close");"Set Measurements...", "area mean integrated add redirect=colony.jpg decimal=3");, "Analyze Particles...", "  show=Outlines display exclude summarize");