Login  Register

Re: Duplicating Images With Symbols

Posted by David Webster on Nov 18, 2009; 8:24pm
URL: http://imagej.273.s1.nabble.com/Duplicating-Images-With-Symbols-tp3690407p3690409.html

Thanks Wayne, works like gangbusters! - David

On Wed, Nov 18, 2009 at 12:04 PM, Wayne Rasband <[hidden email]> wrote:

>  > If I write a macro that uses "setColor(255);drawOval(w/2,
> > h/2, 50,50);" to draw an oval into an image, then I can
> > duplicate the image (i.e. run("Duplicate ... ",... ) and
> > oval is in the duplicate. In Java, if I use
> >
> > Vector list = new Vector(); OvalRoi roi = new
> > OvalRoi(x,y,w,h); roi.setInstanceColor(Color.green);
> > list.addElement(roi);
> >
> > and then duplicate the resulting output image, the oval
> > doesn't show up in the duplicate. Is there a way to insert
> > an oval, or other symbols into an image in a Java program
> > and have them be "duplicatable" outside of the program?
> >
> > David Webster
>
> You can duplicate what the macro code is doing using
>
>    imp = IJ.getImage();
>    ip = imp.getProcessor();
>    ip.setColor(255);
>    ip.drawOval(w/2, h/2, 50, 50);
>    imp.updateAndDraw();
>
> Or you can render an overlay and/or ROI onto the image using
>
>   imp2 = imp.flatten();  // Image>Overlay>Flatten (1.43j or later)
>
> which creates an RGB duplicate of the image with the overlay and any ROI
> embedded in the pixel data.
>
> -wayne
>