Hi all,
I'm interested to know if there's a way to accumulate overlays created at different points in a macro, i'd then like to recall all these overlays later. I'd like to avoid using the roi manager to store them because i have a number of ROI's in it i want to process and if i store the overlays there too i have to filter out the ROI's amongst the overlays. I assume there is no way to query whether a line in the roi manager is an roi or an overlay? An alternative i've tried is to create a blank image and then use Overlay.copy and paste to transfer an overlay to the blank image "overlays" for storage. However, when i copy a second overlay to the overlays image the first overlay is removed so there is never more than one present on the "overlay" image. So firstly i'm wondering why can't multiple overlays appear on the same image when using Overlay.copy/paste? And if this occurs for a reason is there an alternative method for storing overlays? Thanks for the help, Matt -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
On Sep 28, 2014, at 9:39 AM, Matt Pearson wrote:
> Hi all, > > I'm interested to know if there's a way to accumulate overlays created at different points in a macro, i'd then like to recall all these overlays later. I'd like to avoid using the roi manager to store them because i have a number of ROI's in it i want to process and if i store the overlays there too i have to filter out the ROI's amongst the overlays. I assume there is no way to query whether a line in the roi manager is an roi or an overlay? The list in the ROI Manager only contains selections (aka ROIs). An overlay is a collection of selections. You can think of an overlay as an ROI Manager without a GUI. > An alternative i've tried is to create a blank image and then use Overlay.copy and paste to transfer an overlay to the blank image "overlays" for storage. However, when i copy a second overlay to the overlays image the first overlay is removed so there is never more than one present on the "overlay" image. So firstly i'm wondering why can't multiple overlays appear on the same image when using Overlay.copy/paste? And if this occurs for a reason is there an alternative method for storing overlays? Unlike scripting languages and Java, there is no easy way in the macro language to work with multiple overlays. As an example, the following JavaScript creates and displays four overlays. -wayne // JavaScript overlay example imp = IJ.createImage("Untitled", "8-bit black", 500, 500, 1); imp.show(); list = new ArrayList(); list.add(makeOverlay(Color.red,50,50)); list.add(makeOverlay(Color.green,200,50)); list.add(makeOverlay(Color.blue,50,200)); list.add(makeOverlay(Color.yellow,200,200)); for (i=0; i<list.size(); i++) { imp.setOverlay(list.get(i)); IJ.wait(2000); } function makeOverlay(color, xbase, ybase) { var overlay = new Overlay(); var ran = new Random(); for (var i=0; i<10; i++) { var x = xbase + ran.nextFloat()*250; var y = ybase + ran.nextFloat()*250; var roi = new OvalRoi(x,y,25,25); roi.setStrokeColor(color); roi.setStrokeWidth(2); overlay.add(roi); } return overlay; } > > Thanks for the help, > > Matt > > > > -- > The University of Edinburgh is a charitable body, registered in > Scotland, with registration number SC005336. > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi wayne,
Thanks for the info. Having thought about it more I think i can come up with something that means i only have to deal with one overall overlay so hopefully this will resolve my issue. Thanks again, Matt On 2 Oct 2014, at 18:13, "Rasband, Wayne (NIH/NIMH) [E]" <[hidden email]> wrote: > On Sep 28, 2014, at 9:39 AM, Matt Pearson wrote: > >> Hi all, >> >> I'm interested to know if there's a way to accumulate overlays created at different points in a macro, i'd then like to recall all these overlays later. I'd like to avoid using the roi manager to store them because i have a number of ROI's in it i want to process and if i store the overlays there too i have to filter out the ROI's amongst the overlays. I assume there is no way to query whether a line in the roi manager is an roi or an overlay? > > The list in the ROI Manager only contains selections (aka ROIs). An overlay is a collection of selections. You can think of an overlay as an ROI Manager without a GUI. > >> An alternative i've tried is to create a blank image and then use Overlay.copy and paste to transfer an overlay to the blank image "overlays" for storage. However, when i copy a second overlay to the overlays image the first overlay is removed so there is never more than one present on the "overlay" image. So firstly i'm wondering why can't multiple overlays appear on the same image when using Overlay.copy/paste? And if this occurs for a reason is there an alternative method for storing overlays? > > Unlike scripting languages and Java, there is no easy way in the macro language to work with multiple overlays. As an example, the following JavaScript creates and displays four overlays. > > -wayne > > // JavaScript overlay example > imp = IJ.createImage("Untitled", "8-bit black", 500, 500, 1); > imp.show(); > list = new ArrayList(); > list.add(makeOverlay(Color.red,50,50)); > list.add(makeOverlay(Color.green,200,50)); > list.add(makeOverlay(Color.blue,50,200)); > list.add(makeOverlay(Color.yellow,200,200)); > for (i=0; i<list.size(); i++) { > imp.setOverlay(list.get(i)); > IJ.wait(2000); > } > > function makeOverlay(color, xbase, ybase) { > var overlay = new Overlay(); > var ran = new Random(); > for (var i=0; i<10; i++) { > var x = xbase + ran.nextFloat()*250; > var y = ybase + ran.nextFloat()*250; > var roi = new OvalRoi(x,y,25,25); > roi.setStrokeColor(color); > roi.setStrokeWidth(2); > overlay.add(roi); > } > return overlay; > } > > >> >> Thanks for the help, >> >> Matt >> >> >> >> -- >> The University of Edinburgh is a charitable body, registered in >> Scotland, with registration number SC005336. >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336. -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |