Login  Register

Re: Adding text "Destructively" to the image

Posted by Jan Eglinger on Feb 04, 2016; 12:46pm
URL: http://imagej.273.s1.nabble.com/Adding-text-Destructively-to-the-image-tp5015530p5015540.html

Hi David,

On 04.02.2016 12:18, davek604 wrote:
> I'd tried both those options but IJ.run(imp, "Draw", "slice"); requires the
> text to be selected which I can't figure out how to do via a plugin.

An overlay can be activated as a selection by Alt-clicking on it.
In Java, one way to achieve this would be:

Roi[] ovlArray = imp.getOverlay().toArray();
for (Roi roi: ovlArray) {
     imp.setRoi(roi);
     IJ.run(imp, "Draw", "slice");
}


> The flatten option does work but it makes a copy of the slice out of the
> image so I could end up with a lot of slices to save.

You can use

     imp.flattenStack();

to flatten the image stack in-place.
See the javadoc here:
http://javadoc.imagej.net/ImageJ1/index.html?ij/ImagePlus.html

Hope that helps,
Jan

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