[Insight-users] New filter outputs overwrite previous output?
Zachary Pincus
zpincus at stanford.edu
Sat, 17 Apr 2004 15:06:01 -0700
Hello,
I was hoping to re-use a particular filter object for multiple
different image inputs.
My code is something like this:
// Step 1
typename ResampleType::Pointer resampler = ResampleType::New();
resampler->SetTransform(affineReverseTransform);
// Step 2
resampler->SetInput(mask);
resampler->Update();
newMask = resampler->GetOutput();
// Step 3
resampler->SetInput(image);
resampler->Update();
newImage = resampler->GetOutput();
However, after this executed, newMask and newImage are identically the
outputs of the "step 3" code. If I comment out the "step 3" code,
newMask is as it should be.
So it looks like the filter is overwriting it's outputs after the next
update. This isn't unreasonable behavior, but is there a way to make
the filter make a new output image each time it's updated? (So it can
be easily used in this manner.) Currently, I've fixed this by just
creating a new filter object for each new image I want to make -- but
this seems wasteful, since this sort of code is eventually going to go
in an inner loop and I don't want to constantly be creating and
destroying filter objects...
The answer doesn't seem to be in the documentation, which probably is
just a function of me not knowing where to look. Any pointers in the
right direction would be most helpful.
Thanks,
Zach Pincus
Department of Biochemistry and Program in Biomedical Informatics
Stanford University School of Medicine