[Insight-users] Run the same filter several times

Luis Ibanez luis.ibanez at kitware.com
Fri May 2 10:07:37 EDT 2008


Hi Nicolas,

Your code is quite close to the right approach.

What you are missing is to add "DisconnectPipeline()"
before you pass the image as Input to the filter again.


Your code should look like:

  ImageType::ConstPointer image = reader->GetOutput();

   for(int i=0;i<NbrIterations;i++)
      {
      filter->SetInput( image );
      filter->Update();
      image = filter->GetOutput();
      image->DisconnectPipeline();
      }

At this point, you can use "image" as the output
of the last iteration of the filter.


    Regards,


       Luis


---------------------
Nicolas Payet wrote:
> Hi all,
> 
> I would like to do something very simple that consists in applying the 
> same filter several times to an image (at each iteration, the input of 
> the filter is the output at the previous iteration). Basically, this is 
> what I've done so far :
> 
>  
>  ImageType::Pointer image=reader->GetOutput();
> 
>  for (int i=0;i<NbrIterations;i++)
>  
>      {
>     
>      filter->SetInput(image);
>      image=filter->GetOutput();
>      image->Update();
>     
>      }
> 
> This intuitive approach works well, but is a bit slow since I'm working 
> with a large set of data. I was wondering whether there was a more 
> efficient way to implement this. I've already read the post "how to 
> update the content of an image", feeling that it was related to my 
> problem, but I could not find my answer (the number of iterations in my 
> application is around 100, so I cannot really declare 100 filters...)
> 
> Thanks
> 
> Nico
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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