[Insight-developers] Confused about persistance of filter outputs

Hans J. Johnson hans-johnson@uiowa.edu
25 Apr 2003 15:47:18 -0500


Filter and Pipeline experts:

I am trying to create a list of gradient images from a list of images. 
Does the following code produce a list of SmartPointers to gradient
images that persist outside the for loop, or are all the SmartPointers
invalid outside the for loop?
 

std::list<GradImageType::Pointer > ImageCache;
...read in images...

std::list<GradImageType::Pointer > GradientsCache;
for (std::list<itk::Image<unsigned char,3>::Pointer >::const_iterator it
= ImageCache.begin();
it != ImageCache.end();   it++)
{
        typedef itk::GradientImageFilter<itk::Image<unsigned char,3> >
myGradType;
        myGradType::Pointer myGrad=myGradType::New();
        myGrad->SetInput(*it);
        GradientsCache.push_back(myGrad->GetOutput());
}

Thanks,
Hans


-- 
Hans J. Johnson <hans-johnson@uiowa.edu>
The University of Iowa