No outline on Roi in overlays

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

No outline on Roi in overlays

JonNathan
Hi all,

I am trying to add Roi's with specific stroke color and fill color to an overlay, but if the fill color is anything other than "none", the outline stroke color does not show up.  Here is some macro code to recreate what I'm seeing:

run("Blobs (25K)");
makeOval(50, 100, 100, 50);
run("Properties... ", "name=roi1 stroke=red width=3 fill=green");
run("Add Selection...");
makeOval(50, 25, 100, 50);
run("Properties... ", "name=roi2 stroke=red width=3");
run("Add Selection...");

I would expect the first Roi to be green with a red outline, but only the green fill is present.  Any hints?

Jon Marsh
Reply | Threaded
Open this post in threaded view
|

Re: No outline on Roi in overlays

Wayne Rasband-2
> On May 31, 2017, at 4:52 PM, JonNathan <[hidden email]> wrote:
>
> Hi all,
>
> I am trying to add Roi's with specific stroke color and fill color to an
> overlay, but if the fill color is anything other than "none", the outline
> stroke color does not show up.  Here is some macro code to recreate what I'm
> seeing:

A single ROI cannot be both filled and outlined. You need to use two, one filled and the other outlined. Here is a macro example:

   newImage("Untitled", "8-bit black", 400, 400, 1);
   makePolygon(230,70,325,260,55,300);
   run("Fit Spline");
   run("Properties... ", "  fill=green");
   run("Add Selection...");
   run("Select None");
   run("Restore Selection");
   run("Properties... ", "stroke=red width=9");
   run("Add Selection...");
   run("Select None”);

And here is a JavaScript example:

   img = IJ.createImage("Untitled", "8-bit black", 400, 400, 1);
   xpoints = [230, 325, 55];
   ypoints = [70, 260, 300];
   roi1 = new PolygonRoi(xpoints, ypoints, Roi.POLYGON);
   roi1.fitSpline();
   roi1.setFillColor(Color.green);
   overlay = new Overlay();
   overlay.add(roi1);
   roi2 = roi1.clone();
   roi2.setStrokeColor(Color.red);
   roi2.setStrokeWidth(9);
   overlay.add(roi2);
   img.setOverlay(overlay);
   img.show();

-wayne

> run("Blobs (25K)");
> makeOval(50, 100, 100, 50);
> run("Properties... ", "name=roi1 stroke=red width=3 fill=green");
> run("Add Selection...");
> makeOval(50, 25, 100, 50);
> run("Properties... ", "name=roi2 stroke=red width=3");
> run("Add Selection...");
>
> I would expect the first Roi to be green with a red outline, but only the
> green fill is present.  Any hints?
>
> Jon Marsh
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/No-outline-on-Roi-in-overlays-tp5018814.html
> Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: No outline on Roi in overlays

JonNathan
Hi Wayne -- Thanks for the clarification.  I'll use your solution.

Cheers,

Jon