[Insight-users] Save images in a loop

Dan Mueller dan.muel at gmail.com
Fri Nov 21 11:38:36 EST 2008


Hi Fran,

As long as you keep an ImageType::Pointer around, then an image will
stay alive. You should be able to achieve this using a std::vector:

    typedef itk::Image< PixelType, Dimension > ImageType;
    std::vector< ImageType::Pointer > images;

    for (unsigned int i=0; i<10; i++)
        {
        // Do something with a filter perhaps
        filter->Update();
        ImageType::Pointer image = filter->GetOutput();
        image->DisconnectPipeline();
        images->push_back( image );
        }

I have not compiled this (obviously it is incomplete) but it should
give you the idea.

Hope this helps.

Cheers, Dan

2008/11/21 Fran Serrano <sercha at gmail.com>:
> Dear all,
>
> I'm working with consecutive images in a loop and I would like to save some
> of them for using them in the following step. Can anyone give me an idea how
> can I do it? There is any example in the software Guide?
>
> Are containers useful for doing it?
>
> Thanks to all,
>
> Fran
>
> --
> ~~~~~~~~~~~~~~~~Fran~~~~~~~~~~~~~~~~
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list