Posted by
Rasband, Wayne (NIH/NIMH) [E] on
May 21, 2013; 4:31pm
URL: http://imagej.273.s1.nabble.com/Using-overlays-on-image-channels-tp5003054p5003075.html
On May 20, 2013, at 7:45 AM, edsimmons wrote:
> Hi IJ list,
>
> I wonder if someone could help, please?
>
> I'm trying to work out how best to use overlays on an image with two
> channels. I'm using Micro-manager to acquire images (displayed as greyscale
> channels that the user can choose between, not a composite image) and I
> would like to draw on the overlays of individual channels of the same image.
>
> Is this something that is possible to do with IJ directly or do I need to
> code this myself?
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.
-wayne
// 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();
// This macro demonstrates how to create a two
// channel hyperstack and add an overlay to it.
// It requires the ImageJ 1.47r daily build.
requires("1.47r");
channels = 2;
slices = 1;
frames = 10;
newImage("Test", "8-bit black", 500, 500, channels, slices, frames);
Stack.setDisplayMode("grayscale");
// add rectangle that will be displayed on channel 1 of all 10 frames
makeRectangle(100, 100, 100, 100);
Overlay.addSelection;
Overlay.setPosition(1, 1, 0)
// add rectangle that will be displayed on channel 1 of 1st frame
makeRectangle(100, 250, 100, 100);
Overlay.addSelection;
Overlay.setPosition(1, 1, 1)
// add circle that will be displayed on channel 2 of all 10 frames
makeOval(250, 100, 100, 100);
Overlay.addSelection;
Overlay.setPosition(2, 1, 0)
// add circle that will be displayed on channel 2 of 2nd frame
makeOval(250, 250, 100, 100);
Overlay.addSelection;
Overlay.setPosition(2, 1, 2);
Overlay.show;
run("Select None");
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html