<div class="gmail_quote">On Fri, Sep 10, 2010 at 9:20 PM, Julien Michel <span dir="ltr">&lt;<a href="mailto:julien.michel@cnes.fr">julien.michel@cnes.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Dear ITK users and developpers,<br>
<br>
There is something puzzling in the way composite filter implementation is described in the ITK Software Guide (section &quot;How to write a composite filter&quot;).<br>
<br>
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.<br>

<br>
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.<br>
</blockquote><div><br></div><div>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...</div>
<div><br></div><div><span class="Apple-style-span" style="font-family: &#39;Times New Roman&#39;; font-size: medium; "><pre style="word-wrap: break-word; white-space: pre-wrap; ">void GenerateOutputInformation() 
{
  // get pointers to the input and output
  typename Superclass::OutputImagePointer outputPtr = this-&gt;GetOutput();
  typename Superclass::InputImageConstPointer inputPtr  = this-&gt;GetInput();

  // Minipipeline is :
  //   Input -&gt; Crop -&gt; Resample_if_too_anisotropic -&gt; Segment

  miniPipelineFilter1-&gt;SetInput(inputPtr);
  miniPipelineFilter1-&gt;SetParameters(...)<br>  
  miniPipelineFilter2-&gt;SetInput( m_CropFilter-&gt;GetOutput() );<br>  miniPipelineFilter2-&gt;SetParameters(...)<br>  miniPipelineFilter2-&gt;GenerateOutputInformation();</pre><pre style="word-wrap: break-word; white-space: pre-wrap; ">
<br>  outputPtr-&gt;CopyInformation( m_IsotropicResampler-&gt;GetOutput() );
}
</pre><div><br></div><div>Are there filters in ITK that do not do this / are broken ? Or are you referring to some chapter of the guide ?</div><div><br></div><div>Thanks</div><div>--</div><div>karthik</div></span></div><div>
 </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
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.<br>

<br>
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 ?<br>

<br>
Thanks a lot for your answer,<br>
<br>
Best regards,<br>
<br>
Julien Michel<br>
-- <br>
<br>
Julien MICHEL<br>
<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>