Re: Using overlays on image channels

Posted by Jan Eglinger on
URL: http://imagej.273.s1.nabble.com/Using-overlays-on-image-channels-tp5003054p5003076.html

Dear all,

On 21.05.2013 6:31 PM, Rasband, Wayne (NIH/NIMH) [E] wrote:
> You can add overlays to multichannel images. Here are JavaScript and macro examples that create a 2 channel, 10 frame hyperstack and then add an overlay containing a rectangle that is displayed on channel 1 of all 10 frames, a rectangle that is only displayed on channel 1 of frame 1, a circle that is displayed on channel 2 of all 10 frames and a circle that is only displayed only on channel 2 of frame 2.

Thanks, Wayne, for this illustrative code.
Just a note for *Fiji* users: in order for the Javascript example to
work in Fiji, you have to add:

importClass(Packages.ij.gui.Overlay);

to the begining of the code.

Jan

>
>   // This script demonstrates how to create a two
>   // channel hyperstack and add an overlay to it.
>   channels = 2;
>   slices = 1;
>   frames = 10;
>   imp = IJ.createHyperStack("Test", 500, 500, channels, slices, frames, 8);
>   imp.setMode(CompositeImage.GRAYSCALE);
>   overlay = new Overlay();
>   // add rectangle that will be displayed on channel 1 of all 10 frames
>   rect1 = new Roi(100, 100, 100, 100);
>   rect1.setPosition(1, 1, 0);
>   overlay.add(rect1);
>   // add rectangle that will be displayed on channel 1 of 1st frame
>   rect2 = new Roi(100, 250, 100, 100);
>   rect2.setPosition(1, 1, 1);
>   overlay.add(rect2);
>   // add circle that will be displayed on channel 2 of all 10 frames
>   circle1 = new OvalRoi(250, 100, 100, 100);
>   circle1.setPosition(2, 1, 0);
>   overlay.add(circle1);
>   // add circle that will be displayed on channel 2 of 2nd frame
>   circle2 = new OvalRoi(250, 250, 100, 100);
>   circle2.setPosition(2, 1, 2);
>   overlay.add(circle2);
>   imp.setOverlay(overlay);
>   imp.show();
>

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