Login  Register

Re: Overlay and ROI

Posted by Philippe GENDRE on Nov 19, 2013; 11:48am
URL: http://imagej.273.s1.nabble.com/Overlay-and-ROI-tp5005591p5005599.html

Thanks a lot Wayne. Your answer is very useful for me.

Just one question more on this topic : do I have to create as overlay as
rois if I want to move each overlay/roi with a specific value  ?

Best regards,

Philippe


2013/11/19 Rasband, Wayne (NIH/NIMH) [E] <[hidden email]>

> On Nov 18, 2013, at 4:15 PM, Philippe GENDRE wrote:
>
> > Dear List,
> >
> > I need to retrieve the pixels of several ROIs in the same image and to
> > visualize these ROIs.
> >
> > To do that, inside a loop, I draw several rectangles corresponding to
> each
> > ROI (using the rectangular selection tool for example) and  I use the
> > following lines to store the corresponding ROI and to visualize each of
> > them on the image which is a live stream  :
> >
> > roi[i]=img.getRoi();
> > IJ.run("Add Selection...", "");
> >
> > My question is how to change (to translate) the ROIs *and* their
> > corresponding overlay ?
>
> You can use the Overlay.translate(x,y) method to translate the overlay. An
> overlay is essentially an array of ROIs so there is no need to maintain a
> second array. Here is JavaScript code that creates an overlay consisting of
> three rectangles, translates the overlay and then activates, one at a time,
> each of the three rectangles.
>
> -wayne
>
>   imp = IJ.createImage("Untitled", "8-bit black", 500, 500, 1);
>   overlay = new Overlay();
>   overlay.add(new Roi(50, 50, 120, 120));
>   overlay.add(new Roi(200, 150, 120, 120));
>   overlay.add(new Roi(300, 300, 140, 120));
>   imp.setOverlay(overlay);
>   imp.show();
>   IJ.wait(2000);
>   overlay.translate(50, 50);
>   imp.draw();
>   IJ.wait(1000);
>   rois = overlay.toArray();
>   for (i=0; i<rois.length; i++) {
>      imp.setRoi(rois[i]);
>      IJ.wait(1000);
>   }
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html