Login  Register

Re: Multiple ROI Display

Posted by Wayne Rasband on Nov 15, 2009; 5:45am
URL: http://imagej.273.s1.nabble.com/Multiple-ROI-Display-tp3690458p3690460.html

> Wayne,
>
> I tried  rm.runCommand("Show All") but am getting one/off buggy
> behavior. Sometime my circles get displayed and sometimes not.
> For example, if I turn on the macro recorder, then my circles seem
> to be displayed. When it's off, I get nothing. There alos seems to
> be some relationship to how many circles I try to display. Too few,
> and I get nothing.
>
> David Webster

Try displaying the circles in an overlay. Here is a JavaScript example  
that displays 50 circular ROIs at random locations and in random  
colors as an overlay.

-wayne

   if (IJ.getVersion()<"1.43k")
      IJ.error("Requires ImageJ 1.43k or later");
   n = 50;
   w = 1000, h = 700;
   imp = IJ.createImage("Demo","8-bit Ramp",w,h,1);
   imp.show();
   ran = new Random();
   list = new Vector();
   size = w/10;
   for (i=0; i<n; i++) {
       x = ran.nextFloat()*(w-size);
       y = ran.nextFloat()*(h-size);
       roi = new OvalRoi(x,y,size,size);
       color = new Color(ran.nextFloat(),ran.nextFloat(),ran.nextFloat
());
       roi.setStrokeColor(color);
       roi.setStrokeWidth(2);
       list.addElement(roi);
   }
   imp.setDisplayList(list);
   IJ.wait(2000);
   IJ.run(imp,"Hide Overlay","");
   IJ.wait(2000);
   for (i=0; i<n; i++)
       list.get(i).setStrokeWidth(8);
   IJ.run(imp,"Show Overlay","");