images to stack

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

images to stack

Agustin Lobo
Hi!
Is there any way to add images by name to an stack? My images
are not in the same directory, and prefer not to move/copy them.
I can open them all and the use images to stack, but there are
too many and opening them all represents a memory problem.
I can easily have the names (with their paths) in a list, bit do not
know how to add each image to the stack (and close) within a loop.

Thanks
Agus

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

Re: images to stack

Agustin Lobo
Answering myself:
I can open the image and the use
Add Slice, Select All in the new image, and Copy and Paste.
Specifically:
//stack of all CENTERED background images
//we take the name from the imasbackgroundBMP directory
//but actually read from the midastif20121217 where all images (not
only background) live
imasBMPFolder =
"//media/Iomega_HDD/JPIERA/alfacs20121217/MIDAS_alfacs20121217/imasbackgroundBMP/";
imasTIFFolder =
"/media/Iomega_HDD/JPIERA/alfacs20121217/MIDAS_alfacs20121217/midastif20121217/";
images = getFileList(imasBMPFolder);
print(images.length)
open(imasBMPFolder + images[1]);
inputPath = imasTIFFolder + File.nameWithoutExtension + ".tif";
close();
open(inputPath);
run("32-bit");
getStatistics(area, mean, min, max, std);
run("Subtract...", "value=" + mean);
setBatchMode(true);
for (i=1; i<images.length; i++){
        showProgress(i+1, images.length);
        open(imasBMPFolder + images[i]);
        bmpid = getImageID();
        inputima = File.nameWithoutExtension + ".tif";
        inputPath = imasTIFFolder + File.nameWithoutExtension + ".tif";
        selectImage(bmpid);
        close();
        run("Add Slice");
        sliceid = getImageID();
        open(inputPath);
        imaid2 = getImageID();
        run("32-bit");
        getStatistics(area, mean, min, max, std);
        run("Subtract...", "value=" + mean);
        selectWindow(inputima);
        run("Select All");
        run("Copy");
        selectImage(sliceid);
        run("Paste");
        selectWindow(inputima);
        close();
}

Agus

On Thu, Feb 14, 2013 at 5:49 PM, Agustin Lobo <[hidden email]> wrote:

> Hi!
> Is there any way to add images by name to an stack? My images
> are not in the same directory, and prefer not to move/copy them.
> I can open them all and the use images to stack, but there are
> too many and opening them all represents a memory problem.
> I can easily have the names (with their paths) in a list, bit do not
> know how to add each image to the stack (and close) within a loop.
>
> Thanks
> Agus

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

Re: images to stack

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by Agustin Lobo
On Feb 14, 2013, at 11:49 AM, Agustin Lobo wrote:

> Hi!
> Is there any way to add images by name to an stack? My images
> are not in the same directory, and prefer not to move/copy them.
> I can open them all and the use images to stack, but there are
> too many and opening them all represents a memory problem.
> I can easily have the names (with their paths) in a list, bit do not
> know how to add each image to the stack (and close) within a loop.

You can use the File>Import>Stack from List command, which opens a stack, or virtual stack, from a text file or URL containing a list of image file paths. The images can be in different folders but they must all be the same size and type.

This macro demonstrates how to generate a list of images and then use that list to open the images as a virtual stack:

   http://imagej.nih.gov/ij/macros/VirtualStackFromList.txt

And this one demonstrates how to how to open an image series from a remote server:

   http://imagej.nih.gov/ij/macros/OpenStackUsingURLs.txt

-wayne

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

Re: images to stack

Agustin Lobo
This alternative is a lot better and more elegant,
Thanks!
Agus



On Sat, Feb 16, 2013 at 3:43 PM, Rasband, Wayne (NIH/NIMH) [E]
<[hidden email]> wrote:

> On Feb 14, 2013, at 11:49 AM, Agustin Lobo wrote:
>
>> Hi!
>> Is there any way to add images by name to an stack? My images
>> are not in the same directory, and prefer not to move/copy them.
>> I can open them all and the use images to stack, but there are
>> too many and opening them all represents a memory problem.
>> I can easily have the names (with their paths) in a list, bit do not
>> know how to add each image to the stack (and close) within a loop.
>
> You can use the File>Import>Stack from List command, which opens a stack, or virtual stack, from a text file or URL containing a list of image file paths. The images can be in different folders but they must all be the same size and type.
>
> This macro demonstrates how to generate a list of images and then use that list to open the images as a virtual stack:
>
>    http://imagej.nih.gov/ij/macros/VirtualStackFromList.txt
>
> And this one demonstrates how to how to open an image series from a remote server:
>
>    http://imagej.nih.gov/ij/macros/OpenStackUsingURLs.txt
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

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