[Insight-users] How to use GraftOutput()

Luis Ibanez luis.ibanez at kitware.com
Sun Apr 15 10:17:09 EDT 2007


Hi Eve,


GraftOutput() is commonly used when a filter internally uses
other filters in order to process the input images. This is
usually called a "mini-pipeline".

Since the result of the processing is stored in the output
image of the last filter in the mini-pipeline, it is then
necessary to take the output of that filter and "graft" it
as the output of the larger filter.

In general you should simply call GetOutput() and in your
GenerateData() method, compute the pixel values to be stored
in the output image.

Since it seems that you are writing an ITK filter, you should
probably read the tutorial:

http://www.na-mic.org/Wiki/images/b/bc/Insight-Writing-a-New-Filter.ppt


For examples on the uses of GraftOutput() you may want to look
at the GenerateData() method in the file:

    Insight/Code/BasicFilters/
       itkVotingBinaryIterativeHoleFillingImageFilter.txx


You will find many other examples just by grepping for
GraftOutput() in that directory.



BTW: A filter should *NEVER* modify its input.

The only exception to this rule is the InPlace filters,
where for memory allocation reasons, the buffer of the
input image is reused. Otherwise, in general, modifying
the input should be considered a bug.



  Regards,


     Luis


--------------
Eve wrote:
> Hi ITK-users,
> 
> Could someone please explain how and when I should use GraftOutput? 
> 
> If a filter calls this function, does it modify its input as well? What is
> the difference between this and simply calling filter->GetOutput()?
> 
> Alternatively, please point me to references about this function.
> 
> Thanks,
> Evelyn
> 


More information about the Insight-users mailing list