[Insight-users] Composite Filters and GenerateInputRequestedRegion()

Julien Michel julien.michel at cnes.fr
Mon Sep 13 12:00:54 EDT 2010


Karthik Krishnan a écrit :
> On Fri, Sep 10, 2010 at 9:20 PM, Julien Michel <julien.michel at cnes.fr 
> <mailto:julien.michel at cnes.fr>> wrote:
>
>     Dear ITK users and developpers,
>
>     There is something puzzling in the way composite filter
>     implementation is described in the ITK Software Guide (section
>     "How to write a composite filter").
>
>     Let assume that I wish to write a composite filter. The pipeline I
>     want to wrap in this composite filter produces an output image
>     with different size, origin and spacing than the input image. This
>     pipeline also supports streaming with a non-trivial input
>     requested region generation.
>
>     If I follow what is described in the Software Guide, the output of
>     the internal minipipeline (which is the real one) will substitute
>     to the output of the composite filter once the Graft*() methods
>     are called, which means at the end of the GenerateData() method.
>     Unfortunately, at this stage we already missed the
>     GenerateOutputInformation()/GenerateInputRequestedRegion()
>     negociation, which means that the internal minipipeline filters
>     are not used to compute what the real output information and
>     intput requested region are (like in a standard pipeline
>     execution), but instead the default implementation of these
>     methods are called.
>
>
> Indeed. One should write the GenerateOutputInformation method of the 
> class as something like below. They should be delegated to the 
> internal minipipeline filters, then its GenerateOutputInformation() be 
> called and then the CopyInformation method invoked on the outputPtr to 
> copy the information from the minipipeline... something like...
>
> void GenerateOutputInformation() 
> {
>   // get pointers to the input and output
>   typename Superclass::OutputImagePointer outputPtr = this->GetOutput();
>   typename Superclass::InputImageConstPointer inputPtr  = this->GetInput();
>
>   // Minipipeline is :
>   //   Input -> Crop -> Resample_if_too_anisotropic -> Segment
>
>   miniPipelineFilter1->SetInput(inputPtr);
>   miniPipelineFilter1->SetParameters(...)
>   
>   miniPipelineFilter2->SetInput( m_CropFilter->GetOutput() );
>   miniPipelineFilter2->SetParameters(...)
>   miniPipelineFilter2->GenerateOutputInformation();
>   outputPtr->CopyInformation( m_IsotropicResampler->GetOutput() );
> }
>   
>
> Are there filters in ITK that do not do this / are broken ? Or are you 
> referring to some chapter of the guide ?
Thanks for your answer. I am refering to the Composite Filter chapter 
from the Software Guide. I have been looking for a more complete example 
of composite filter in ITK filters, but it appears that most of the 
composite filter I looked either do not implement 
GenerateOutputInformation()/GenerateInputRequestedRegion() or implement 
the latter with a SetRequestedRegionToLargestPossibleRegion() on the input.

Do you have any complete example I can use as a basis for my own filters ?

Regards,

Julien
-- 

Julien MICHEL
CNES - DCT/SI/AP - BPI 1219
18, avenue Edouard Belin
31401 Toulouse Cedex 09 - France
Tel: +33 561 282 894 - Fax: +33 561 283 109 



More information about the Insight-users mailing list