[Insight-users] New filter outputs overwrite previous output?

Luis Ibanez luis.ibanez at kitware.com
Sat, 17 Apr 2004 21:58:18 -0400


Hi Zach,

This is a natural behavior of the DataPipeline
architecture, the output should be rewritten
upon Updates().


You may want to use the DisconnectPipeline()
method in between the invocations of Update()
in your filter.

The following message may help:
http://www.itk.org/pipermail/insight-users/2003-December/005975.html

---

For example, between Step 2 and Step 3 you should
call newMask->DisconnectPipeline();

 >         // Step 2
 >         resampler->SetInput(mask);
 >         resampler->Update();
 >         newMask = resampler->GetOutput();
 >

    newMask->DisconnectPipeline();  // <<--- Add This

 >
 >         // Step 3
 >         resampler->SetInput(image);
 >         resampler->Update();
 >         newImage = resampler->GetOutput();


Note that you call this method on the output image,
not in the filter.


Please let us know if you have further questions,


    Thanks


      Luis


----------------------
Zachary Pincus wrote:

> 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
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>