[Insight-users] container for iterators of images

Hila Hiler hilahiler at gmail.com
Mon Apr 23 08:27:31 EDT 2012


Hi All,

I'd like to generate a new image by summarizing some other images in the
same dimensions.
So I generated a new image and a std::list for the images iterators.
(actually, I thought that this dynamic container is the best way to mange
an unknown number of images)

For now, it isn't working because I don't know how to forward the image's
iterator from that vector. in other words, how do I do the same as:
output_it++ from a vector?

Here is my code:

    typedef itk::ImageRegionIterator            <ImageType>
iteratorType;
    typedef itk::ImageRegionConstIterator    <ImageType>
constIteratorType;

    constIteratorType    first_it    (first_img,
first_img->GetRequestedRegion());
    iteratorType            output_it (output_img, output_img->
GetRequestedRegion());

    std::list<constIteratorType> list;
    std::list<constIteratorType>::iterator it;

    list.push_back(first_it);

    if (second_img.IsNotNull())
    {
        constIteratorType second_it (second_img,
second_img->GetRequestedRegion());
        list.push_back (second_it);
    }

    //initialize all the iterators at the begin of input images
    for(it = list.begin(); it < list.end(); it++)
    {
        it->GoToBegin();
    }

    for(output_it.GoToBegin(); !output_it.IsAtEnd(); ++output_it)
    {
        for(it = list.begin(); it < list.end(); it++)//move on the images
and get at each iteration the pixel value and insert to the new image
        {
            output_val = it->Get() + output_val;  //get values from each
image and insert in the output image
            // How do I forward the image's iterator from here ?????
        }

        output_it.Set(output_val);

    }



Any thoughts would be very welcome ...
Hila
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120423/e8ed02e2/attachment.htm>


More information about the Insight-users mailing list