Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jul 08, 2015; 8:57pm
URL: http://imagej.273.s1.nabble.com/How-to-fill-a-selection-with-a-different-color-while-still-keep-the-line-color-tp5013457p5013474.html
On Jul 8, 2015, at 12:20 PM, WangPing <
[hidden email]<mailto:
[hidden email]>> wrote:
Dear Philippe,
Thank you for your response, but my question is slightly different. I draw an ROI (for example an oval, or a polygon) it should have a color of its boundary. Then I fill the ROI with one color (press Y), then the ROI boundary disappears. My question was how to still display the boundary when the ROI is filled with some color.
A single selection cannot be filled and have a boundary at the same time, but you can use an overlay as a work around. The following macro creates an overlay containing a blue filled oval with a red boundary and transparent magenta filled polygon with a yellow boundary.
newImage("Untitled", "8-bit ramp", 512, 512, 1);
makeOval(86, 70, 162, 116);
Overlay.addSelection("", 0, "blue");
makeOval(86, 70, 162, 116);
Overlay.addSelection("red", 3);
makePolygon(312,195,187,335,440,387,417,240);
Overlay.addSelection("", 0, "22ff00ff");
makePolygon(312,195,187,335,440,387,417,240);
Overlay.addSelection("yellow", 7);
run("Select None");
And here is a Javascript version:
imp = IJ.createImage("Untitled", "8-bit ramp", 512, 512, 1);
overlay = new Overlay();
oval1 = new OvalRoi(86, 70, 162, 116);
oval1.setFillColor(Color.blue);
overlay.add(oval1);
oval2 = oval1.clone();
oval2.setStrokeColor(Color.red);
oval2.setStrokeWidth(3);
overlay.add(oval2);
xpoints = [312,187,440,417];
ypoints = [195,335,387,240];
polygon1 = new PolygonRoi(xpoints,ypoints,Roi.POLYGON);
polygon1.setFillColor(new Color(1,0,1,0.13));
overlay.add(polygon1);
polygon2 = polygon1.clone();
polygon2.setStrokeColor(Color.yellow);
polygon2.setStrokeWidth(7);
overlay.add(polygon2);
imp.setOverlay(overlay);
imp.show();
[cid:042A939B-279C-4341-A0C0-BDCA4A074449@home]
-wayne
Date: Wed, 8 Jul 2015 11:14:24 +0200
From:
[hidden email]<mailto:
[hidden email]>
Subject: Re: How to fill a selection with a different color while still keep the line color?
To:
[hidden email]<mailto:
[hidden email]>
Dear Ping Wang,
I'm not sure whether I misunderstood what you are looking for.
But is the feature you are interested not just the Edit->Draw (or Ctrl + D)
feature.
It will draw a line which color is the active one and thickness can be
defined in Edit->Options->Line_width...
My best regards,
Philippe
-----Message d'origine-----
De : ImageJ Interest Group [mailto:
[hidden email]] De la part de
WangPing
Envoyé : mardi 7 juillet 2015 21:07
À :
[hidden email]<mailto:
[hidden email]>
Objet : How to fill a selection with a different color while still keep the
line color?
Dear List,
I drew an ROI with red color, now I filled it with a different color (for
example green), then I found the red boundary line of the ROI was not shown
any more. I wonder if anyone knows how to keep the line color for the ROI?
Thanks.
ping wang
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html