automatically save images from a stack

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

automatically save images from a stack

OBEID Patricia 154904
Good morning all
I have a stack with n images on which I want to make a bar scale appear (I know how).
I then want to individually save each image (with scale bar) in the stack as an individual image (still with the scale).
How to write this last step to integrate it into a macro?
Today I do Stack / Convert stack to images and manually save each image
Thank you for your help
Cordially
Patricia






--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: automatically save images from a stack

Herbie
Greetings Patricia,

below please find a demo-macro that saves all images of the demo-stack
in PNG-format to the "download folder". PNG implies that the scale bar
is flattened ("burned" to the image). If you want to keep the bar as an
overlay, you need to save as "tif" instead.

//
run("MRI Stack");
nme = split(getTitle(), ".");
run("Set Scale...", "distance=210 known=12 unit=cm");
run("Scale Bar...", "width=3 height=3 font=12 color=White
background=None location=[Lower Right] bold overlay");
path = getDir("downloads") + nme[0] + "_slice#";
for ( i=0; i<nSlices; i++ ) {
    setSlice(i+1);
    saveAs("png", path+(i+1));
}
//

Regards

Herbie

:::::::::::::::::::::::::::::::::::::::::::::::::::
Am 04.06.21 um 13:20 schrieb OBEID Patricia 154904:
> Good morning all
> I have a stack with n images on which I want to make a bar scale appear (I know how).
> I then want to individually save each image (with scale bar) in the stack as an individual image (still with the scale).
> How to write this last step to integrate it into a macro?
> Today I do Stack / Convert stack to images and manually save each image
> Thank you for your help
> Cordially
> Patricia

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