<div class="gmail_quote">On Fri, Sep 10, 2010 at 9:20 PM, Julien Michel <span dir="ltr"><<a href="mailto:julien.michel@cnes.fr">julien.michel@cnes.fr</a>></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 "How to write a composite filter").<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: 'Times New Roman'; 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->GetOutput();
typename Superclass::InputImageConstPointer inputPtr = this->GetInput();
// Minipipeline is :
// Input -> Crop -> Resample_if_too_anisotropic -> Segment
miniPipelineFilter1->SetInput(inputPtr);
miniPipelineFilter1->SetParameters(...)<br>
miniPipelineFilter2->SetInput( m_CropFilter->GetOutput() );<br> miniPipelineFilter2->SetParameters(...)<br> miniPipelineFilter2->GenerateOutputInformation();</pre><pre style="word-wrap: break-word; white-space: pre-wrap; ">
<br> outputPtr->CopyInformation( m_IsotropicResampler->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>