[Insight-users] Composite Filters and GenerateInputRequestedRegion()

Karthik Krishnan karthik.krishnan at kitware.com
Sun Sep 12 07:33:16 EDT 2010


On Fri, Sep 10, 2010 at 9:20 PM, Julien Michel <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
--
karthik


>
> One workaround is to rewrite these methods by either duplicating output
> information and input requested region generation from the internal
> minipipeline or try to call the appropriate minipipeline methods to get
> things right.
>
> A composite filter should exactly behave like the pipeline it embeds not
> only for the GenerateData() part, but also during the former stages of
> pipeline execution. Did I miss something (for quite a long time) ? Is there
> any way to get the composite filter to behave properly is such cases ?
>
> Thanks a lot for your answer,
>
> Best regards,
>
> Julien Michel
> --
>
> Julien MICHEL
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100912/97f51b3f/attachment.htm>


More information about the Insight-users mailing list