Multiple ROI Display

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

Multiple ROI Display

David Webster
All,

I have a plugin (Java) that uses oval shaped ROIs to display detected
circles. I use:

RoiManager rm = new RoiManager();
.
.
.
IJ.makeOval(x-r, y-r, 2*r+1,2*r+1);
rm.runCommand( "Add");

To put them into the ROI manager and

rm.runCommand("Combine");

To display them. But when the overlap, the corresponding sections are not
shown. If I go to the menus, I can click the "Show All" in the ROI Manager
window, to get complete circles. But, this doesn't seem to be an option
that I can use with the run runCommand() method. The macro recorder shows
this as a setOption("Show All",true) macro command, and this is what sgows
up if I "create" this as a plugin. But, the compiler can't find it and I
can't find the setOption() method in the API.

Help!!

David Webster
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

Wayne Rasband
On Nov 14, 2009, at 2:45 PM, David William Webster wrote:

> All,
>
> I have a plugin (Java) that uses oval shaped ROIs to
> display detected circles. I use:
>
> RoiManager rm = new RoiManager();
> .
> .
> .
> IJ.makeOval(x-r, y-r, 2*r+1,2*r+1);
> rm.runCommand( "Add");
>
> To put them into the ROI manager and
>
> rm.runCommand("Combine");
>
> To display them. But when the overlap, the corresponding sections
> are not shown. If I go to the menus, I can click the "Show All" in the
> ROI Manager window, to get complete circles. But, this doesn't
> seem to be an option that I can use with the run runCommand() method.
> The macro recorder show this as a setOption("Show All",true) macro
> command, and this is what sgows up if I "create" this as a plugin.  
> But,
> the compiler can't find it and I can't find the setOption() method  
> in the API.

Use

     rm.runCommand("Show All");

  which is available in the 1.43l daily build. Use

     rm.runCommand("Show None");

to hide the ROIs. I will fix the recorder next week.

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

David Webster
In reply to this post by David Webster
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
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

Wayne Rasband
> 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","");
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

David Webster
Wayne,

I assume I can do that in Java as well!

FYI, I am using Windows XP/SP3, Jave 1.60_11, and Image J ver k (or daily
build). In any case, my test plugin does not show the same misbehavior as my
filter. I can zip up the code thta sows the misbehvior and send it to you if
you wish.

David Webtser

On Sat, Nov 14, 2009 at 9:45 PM, Wayne Rasband <[hidden email]> wrote:

>   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","");
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

David Webster
In reply to this post by Wayne Rasband
Wayne,

When I use th "Show Overlay" option in Java, I only get one circle

On Sat, Nov 14, 2009 at 9:45 PM, Wayne Rasband <[hidden email]> wrote:

>   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","");
>
Reply | Threaded
Open this post in threaded view
|

Re: Multiple ROI Display

David Webster
In reply to this post by Wayne Rasband
Wayne,

OK, got a plugin that misbehaves. Build it with version 1.43I5. Select run
time option "Use Daily Build" to do the rm.runCommand("Show All") or
otherwise rm.runCommand("Combine"). The "Use Daily Build" option display
nothing until you select or something like
"Number of Circles = 15". The non daily build option doesn't care.

David Webster



import ij.*;
import ij.process.*;
import ij.gui.*;
import ij.plugin.filter.PlugInFilter;
import ij.plugin.frame.RoiManager;
public class TestDraw_ implements PlugInFilter
{
 ImagePlus imp;
 public int setup(String arg, ImagePlus imp) {
  this.imp = imp;
  return DOES_ALL;
 }
 public void run(ImageProcessor ip)
 {
  GenericDialog gd = new GenericDialog("Circle Params", IJ.getInstance());
        gd.addNumericField("Number of circles", 3, 0);
  gd.addCheckbox("Use Daily Build", false);
  gd.showDialog();
  int cmax    = (int)gd.getNextNumber();
  boolean usedb = gd.getNextBoolean();
  int x[] = new int[cmax]; int y[] = new int[100]; int r[] = new int[100];
  for(int k = 0; k < cmax; k++)
  {
   x[k] = 20*k+20; y[k] = 100; r[k]=10;
  }
  drawEllipticalOutline( ip, x,y,r, usedb);
 }
 void drawEllipticalOutline( ImageProcessor ip, int x[], int y[], int r[],
boolean usedb)
 {
  ImagePlus imp2  = new ImagePlus(x.length+" Circles Found", ip);
  imp2.show();
  RoiManager rm  = new RoiManager();
  int numdrawn  = 0;
  for(int k = 0; k < x.length; k++)
  {
   IJ.makeOval(x[k]-r[k], y[k]-r[k], 2*r[k]+1,2*r[k]+1);
   rm.runCommand( "Add");
   numdrawn++;
  }
  if( usedb == true)
   rm.runCommand("Show All");
  else
   rm.runCommand("Combine");
  rm.close();
 }
}

On Sat, Nov 14, 2009 at 9:45 PM, Wayne Rasband <[hidden email]> wrote:

>   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","");
>