Get the overlay from one slice

Hi,
I have a .tif file which is a stack. Each slice has a different overlay. How can I get an overlay from one slice? I tried getting the overlay and then cropping it: (there are 9 slices and I want slice 1, for example)

sliceOvr = imp.getOverlay();
sliceOvr.crop(2,9);
var sliceOvrSize = sliceOvr.size();

The problem is that the number of ROIs in the overlay remained the total number of ROIs from all of the overlays of all of the slices. How can I get the overlay from only the slice I’m interested in?

Thanks,
Avital

Hello Avital,

does this example help you (an overlay have to be associated with a slice):

http://imagej.1557.x6.nabble.com/Overlays-and-stack-slices-td3682121.html

Does it help if you use the image slice ImageProcessor before (not tested!):

selectedSlice=1;
stack = imp.getImageStack();
/* Get the image processor of the slice! */
ip = stack.getProcessor(selectedSlice);
sliceOvr=ip.getOverlay();
1 Like

Thanks - now I understand how to associate Rois with specific slices. And is there a way to do the opposite, i.e., to associate certain Rois with all of the slices of the stack?

Would’nt it be enough to set the overlay to the ImagePlus object?

ImageJ API:

http://imagej.net/developer/api/ij/ImagePlus.html#setOverlay-ij.gui.Overlay-

Thanks - I set it with the gui, but somehow some of the Rois are associated with a specific slice.