[Insight-users] How to re-use a filter output?

Lemeur Yann Yann.Lemeur at stage.cnes.fr
Thu Jul 15 03:08:28 EDT 2004


Thanks Luis,

I had seen the GraftOutput() method in a mini-pipeline (it was itkWatershedImageFilter). But the problem is that my filters don't give an image as output. So there aren't an ImageToImageFilter and then, I can't use the GraphtOutput() method which is implemented in itkImageSource.
I suppose the solution is to make such GraphtOutput method for my output object, but this is equivalent to a copy. Since my output object can be very heavy, I wanted to avoid this copy.
Is there really no mean to collect the output of my last filter in the output of the mini-pipeline by pointer?

thanks a lot!

Yann 



> ----------
> De : 	Luis Ibanez[SMTP:luis.ibanez at kitware.com]
> Date :	mardi 13 juillet 2004 22:19
> A :	Lemeur Yann
> Cc :	insight-users at itk.org
> Objet :	Re: [Insight-users] How to re-use a filter output?
> 
> 
> Hi Lemeur,
> 
> When you create a filter with a mini-pipeline inside
> You should use GraftOutput() in order to take the output
> image of your mini-pipeline and graft it as the output of
> your own filter.
> 
> 
> For an example, you may want to look a the files
> 
>    Insight/Code/BasicFilter/
>     itkSmoothingRecursiveGaussianImageFilter.txx
> 
> 
> In your code it will be something like
> 
>         this->GraftOutput( M->GetOutput() );
> 
> instead of
> 
>         this->SetNthOutput( output ).
> 
> 
> Regards,
> 
> 
>     Luis,
> 
> 
> ------------------
> 
> Lemeur Yann wrote:
> 
> > Hi all!
> > 
> > I'm confronted to a problem with filters derived from itkProcessObject.
> > I've made my own filters (3 filters: A, B and C) which use some DataObjects I've also created.
> > In order to simplify the use of these filters, I've packed them in one filter called M.
> > In the GenerateData() of M, the three filters are executed to produce the output of M (this output is a Tree, a class I've made):
> > 
> > M::GenerateData()
> > {
> > 		.....
> > 		.....
> > 		.....
> > 		
> > typename TreeType::Pointer output= this->GetOutput();
> > 
> > A->SetInput(M->GetInput());
> > B->SetInput(A->GetOutput());
> > C->SetInput(B->GetOutput());
> > 
> > output=M->GetOutput();
> > C->Update();
> > 
> > this->SetNthOutput(0,output);
> > 
> > } // end of M::GenerateData()
> > 
> > In a main file, I've written:
> > 
> > TreeType::Pointer tree=M->GetOutput();
> > M->Update();
> > 
> > I've seen that the output var is ok after the C->Update() in the M::GenerateData() method. But in my main program, the pointer tree seems to be assigned to an empty Tree.
> > 
> > I think the problem is that the GetOutput() method return a raw pointer so the output var is not available outside the scope of GenerateData() (it might be deleted somewhere...).
> > So I can't produce the output of M!
> > 
> > Daes anybody know how to link the output of M whith the output of C, without copying the Tree objects (ie without making *output=*(C->GetOutput()) ) ?
> > 
> > Thanks.    
> > 
> > _______________________________________________
> > 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