[Insight-users] Using Update() in a loop without loosing efficiency

Luis Ibanez luis.ibanez at kitware.com
Sun Feb 4 14:10:07 EST 2007



Hi Ali,


1) Yes you need to call Update()

2) It will not be painfully slow,
    at least not more than it has to be.
    The update chain in the pipeline only
    triggers the filters that *DO NEED*
    to be updated.

Note that if you are planning on passing
the output image as the input for the next
iteration you *MUST* disconnect the output
of the Add filter. Something like:



      adder->SetInput1( image1 );
      adder->SetInput2( image2 );

      for( unsigned int i=0; i<n; i++)
        {
        adder->Update();
        ImageType::Pointer result =
          adder->GetOutput();
        result->DisconnectPipeline();
        adder->SetInput2( result )
        }



----

  That being said....

Adding an image many times to itself seems to
be a very inneficient way of multiplying an
image by an scalar....


You could even do this by just using an ImageAdaptor,
as described in the ITK Software Guide.

of by creating your own variation of the
itkUnaryFunctorImageFilter, using a Functor
that multiplies the image by a scalar.



I'm guessing that you probably are making
small changes to the images that you pass
as input to the add filter...



    Regards,


       Luis


--------------
Ali - wrote:
> Hi,
> 
> I am trying to add many the same image to itself in a loop by 
> AddImageFilter.
> 
> (1) If I do not call Update at the end of each loop, would it not work 
> properly?
> 
> (2) If I use Update() at the end of each loop, this will be painfully 
> slow as Update()
> tries to also update the image reader and, unnecessarily, the same image 
> is read
> many times taking a very long time to finish the loop. How can I use 
> Update() efficiently?
> 
> ------------------------------------------------------------------------
> Get connected - Use your Hotmail address to sign into Windows Live 
> Messenger now. Connect now! <http://get.live.com/messenger/overview>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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