Login  Register

Multiple Circular ROI

Posted by kiran kumar-2-3 on Aug 08, 2005; 7:15pm
URL: http://imagej.273.s1.nabble.com/ContrastAdjuster-plugin-tp3705076p3705078.html

Hello group,
 
  I am writing a plugin that needs to generate multiple circular ROI of different coordinates and radius automatically and display all ROI's on the image. I am successfully able to create multiple ROI over an image but unable to display all Circular ROI's over an images.  I have attached my code with this mail. Could anyone help me to find a way out.
 
Thanks,
 
Regards,
Kiran
 
Here is my code
 
public class smart_ implements PlugInFilter {
 ImagePlus imp;     //20
 OvalRoi r1;
 RoiManager x1;
 
 
 public int setup(String arg, ImagePlus imp) {
  //this.imp = imp;
  if (arg.equals("about"))  //30
   {showAbout(); return DONE;}
  return DOES_8G+DOES_STACKS+SUPPORTS_MASKING;
 }
 
 public void run(ImageProcessor ip) {
  IJ.showMessage(" Scanning Microscope Analysis and Resolution Testing ");
   
  GenericDialog gd = new GenericDialog("Select one Method ");
  gd.addCheckbox("Manual Resolution Test ",true);
  gd.addCheckbox("Automeasure Resolution ",false);
  gd.addCheckbox("Resolution from Two Images ",false);
  gd.addCheckbox("S/N Ratio ",false);
  gd.showDialog();
  if(gd.wasCanceled()) {
   IJ.error("PlugIn canceled!");
   return;}
 
  boolean a,b,c,d;
  a = gd.getNextBoolean();
  b = gd.getNextBoolean();
  c = gd.getNextBoolean();
  d = gd.getNextBoolean();
 
  if(a== true & b == true | c == true & d == true | a== true & c == true | a== true & d == true | b== true & c == true | b== true & d == true ) {
  IJ.error("Select only one method ");
  return;}
  else if(a == true)
  Manual_Resolution(ip);
  else if(b == true)
  Automeasure_Resolution(ip);
  else if(c == true)
  TwoImage_Resolution(ip);
  else if(d == true)
  SNR_Calculation(ip);  
       //40
 }
 
 
   public void Manual_Resolution(ImageProcessor ip) {
 
  int PixCount = ip.getWidth();
  double widthum = IJ.getNumber("Enter Image width in um",1.0); /* get input from the user */
  IJ.showMessage("widthum="+widthum);
  double Pixperum = PixCount/widthum;
  double Pixsize = 1000/Pixperum;
  IJ.showMessage("pixsize="+Pixsize);    /* pixel size in nm/pixel */ //50
  Rectangle roi = ip.getRoi();
 
  int centerx = roi.x+roi.width/2;    /* setting center of ROI  */
  int centery = roi.y+roi.height/2;
  IJ.showMessage("xcor"+roi.x);
  IJ.showMessage("ycor"+roi.y);
 
  IJ.doCommand("FFT");
  IJ.wait(100);
    double rfactor = (1000*roi.width)/Pixperum;
  double rUser[] = { 0.1, 0.2, 0.3, 0.5, 0.7, 1, 1.5, 2, 2.5, 3, 4, 5, 7, 10, 20, 30, 50, 70, 100, 150 };  
  IJ.showMessage("FFT is calculated");
 
  /*  Draw the calibration rings */
 
  ImagePlus imp = WindowManager.getCurrentImage();  //70
  ip = imp.getProcessor();
   
  IJ.showMessage("Adjust threshold");
  IJ.run("Threshold...");
  IJ.wait(9000);       //80
  IJ.showMessage("Threshold is done");
   
  for( int m = 1; m<=20; m++) {
  int n = 20 - m;
  int radius = (int) Math.round((500*roi.width)/(Pixperum*rUser[n]));
  if((radius<roi.width/2) & (radius>roi.width/10)) {
   int x1 = (int) roi.width/2-radius;
  int y1 = (int) roi.height/2-radius;
  imp.setRoi( new OvalRoi(x1,y1,2*radius,2*radius,imp));  //90
 
     
  /* Annotate the rings */
 
  double theta = 1.57*(1-Math.random());
  int radX = (int) Math.round(radius * Math.cos(theta)-1);
  int radY = (int) Math.round(radius * Math.sin(theta)-1);  //100
  IJ.showMessage("rUser[]"+rUser[n]);
   
  }
      }
   }


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com