<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello,<div><br></div><div>You should look at the different types these methods are returning as thy are different an sometime incompatible. The warning message says what the problem is:</div><div><br></div><div>WARNING: In /usr/local/include/ITK-4.1/itkImageSource.hxx, line 112<br>DanielssonDistanceMapImageFilter (0x26707d0): dynamic_cast to output&nbsp;<br>type failed</div><div><br></div><div>These are the methods you should be come familiar with:</div><div><div><br></div><div>OutputImageType * <span class="Apple-tab-span" style="white-space:pre">        </span>ImageSource::GetOutput (unsigned int idx)</div></div><div><br></div><div>VectorImageType * <span class="Apple-tab-span" style="white-space:pre">        DanielssonDistanceMapImageFilter</span>::GetVectorDistanceMap (void)</div><div><br></div><div><br></div><div>Then there is:</div><div>DataObject * <span class="Apple-tab-span" style="white-space:pre">        </span>ProcessObject::GetOutput (const DataObjectIdentifierType &amp;key)</div><div><br></div><div>You can perform a dynamic_cast on the return of the ProcessObject's method to the correct image type. It is best to check that the result is not NULL in case the dynamic_cast fails.</div><div><br></div><div>Brad</div><div><br><div><div>On Jun 14, 2012, at 11:41 AM, Ramón Casero Cañas wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br>Hi,<br><br>The problem in brief:<br><br>I'm finding that itk::DanielssonDistanceMapImageFilter (derived from <br>itk::ImageToImageFilter) is returning NULL for the 2nd and 3rd outputs <br>when using the method GetOutput(i), while returning correct pointers <br>when using the method GetVectorDistanceMap().<br><br>this-&gt;derivedFilter-&gt;GetOutput(0) = 0x26750a0<br>this-&gt;derivedFilter-&gt;GetOutput(1) = 0<br>this-&gt;derivedFilter-&gt;GetOutput(2) = 0<br>this-&gt;derivedFilter-&gt;GetOutput() = 0x26750a0<br>this-&gt;derivedFilter-&gt;GetVoronoiMap() = 0x2674cb0<br>this-&gt;derivedFilter-&gt;GetVectorDistanceMap() = 0x2675480<br><br><br><br>The problem in detail:<br><br>I have a class with a pointer to a filter<br><br>class MexBaseFilter {<br><br>protected:<br><br>typedef typename itk::ImageToImageFilter&lt;double, double&gt; <br>ImageToImageFilterType;<br><br>typename ImageToImageFilterType::Pointer filter;<br><br>};<br><br>Then a derived class with the DanielssonDistance filter, which derives <br>from itk::ImageToImageFilter<br><br>class MexDanielssonDistanceMapImageFilter :<br> &nbsp;&nbsp;public MexBaseFilter {<br><br>private:<br> &nbsp;&nbsp;typedef itk::DanielssonDistanceMapImageFilter&lt;<br> &nbsp;&nbsp;itk::Image&lt;double, 3&gt;,<br> &nbsp;&nbsp;itk::Image&lt;double, 3&gt; &gt; DerivedImageToImageFilterType;<br><br> &nbsp;&nbsp;typename DerivedImageToImageFilterType::Pointer derivedFilter;<br><br>};<br><br><br>The filter gets instantiated in the constructor of the derived class, <br>and derivedFilter just points to it, using a dynamic_cast that compiles <br>thanks to polymorphism<br><br><br>MexDanielssonDistanceMapImageFilter::MexDanielssonDistanceMapImageFilter() <br>: MexBaseFilter() {<br><br> &nbsp;&nbsp;// using polymorphism<br> &nbsp;&nbsp;// (this-&gt;filter is ImageToImageFilterType)<br> &nbsp;&nbsp;this-&gt;filter = DerivedImageToImageFilterType::New();<br><br> &nbsp;&nbsp;derivedFilter =<br> &nbsp;&nbsp;&nbsp;&nbsp;dynamic_cast&lt;DerivedImageToImageFilterType <br>*&gt;(this-&gt;filter.GetPointer());<br><br>}<br><br><br>Then inputs and parameters are passed to the filter, filter-&gt;Update() is <br>run, and later a method gets called to inspect the outputs of the filter<br><br>void MexDanielssonDistanceMapImageFilter::InspectOutputs() {<br><br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetOutput(0) = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetOutput(0) &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetOutput(1) = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetOutput(1) &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetOutput(2) = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetOutput(2) &lt;&lt; std::endl;<br><br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetOutput() = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetOutput() &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetVoronoiMap() = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetVoronoiMap() &lt;&lt; std::endl;<br> &nbsp;&nbsp;&nbsp;&nbsp;std::cout &lt;&lt; "this-&gt;derivedFilter-&gt;GetVectorDistanceMap() = "<br> &nbsp;&nbsp;&nbsp;&nbsp;<span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;&lt; this-&gt;derivedFilter-&gt;GetVectorDistanceMap() &lt;&lt; std::endl;<br><br>}<br><br>As can be seen from the following output, it seems that the 2nd and 3rd <br>outputs from the filter have been correctly created, and can be accessed <br>with methods GetVoronoiMap() and GetVectorDistanceMap(), but not with <br>GetOutput(i).<br><br>&lt;SCREEN&gt;<br>this-&gt;derivedFilter = DanielssonDistanceMapImageFilter (0x26707d0)<br> &nbsp;&nbsp;RTTI typeinfo: <br>itk::DanielssonDistanceMapImageFilter&lt;itk::Image&lt;short, 3u&gt;, <br>itk::Image&lt;unsigned char, 3u&gt;, itk::Image&lt;short, 3u&gt; &gt;<br> &nbsp;&nbsp;Reference Count: 3<br> &nbsp;&nbsp;Modified Time: 82<br> &nbsp;&nbsp;Debug: Off<br> &nbsp;&nbsp;Observers:<br> &nbsp;&nbsp;&nbsp;&nbsp;none<br> &nbsp;&nbsp;Inputs:<br> &nbsp;&nbsp;&nbsp;&nbsp;Primary: (0x2679d50) *<br> &nbsp;&nbsp;Required Input Names: Primary<br> &nbsp;&nbsp;Outputs:<br> &nbsp;&nbsp;&nbsp;&nbsp;Primary: (0x26750a0)<br> &nbsp;&nbsp;&nbsp;&nbsp;IndexedDataObject1: (0x2674cb0)<br> &nbsp;&nbsp;&nbsp;&nbsp;IndexedDataObject2: (0x2675480)<br> &nbsp;&nbsp;NumberOfIndexedInputs: 1<br> &nbsp;&nbsp;NumberOfRequiredInputs: 1<br> &nbsp;&nbsp;NumberOfIndexedOutputs: 3<br> &nbsp;&nbsp;NumberOfRequiredOutputs: 3<br> &nbsp;&nbsp;Number Of Threads: 4<br> &nbsp;&nbsp;ReleaseDataFlag: Off<br> &nbsp;&nbsp;ReleaseDataBeforeUpdateFlag: Off<br> &nbsp;&nbsp;AbortGenerateData: Off<br> &nbsp;&nbsp;Progress: 0.8<br> &nbsp;&nbsp;Multithreader:<br> &nbsp;&nbsp;&nbsp;&nbsp;RTTI typeinfo: &nbsp;&nbsp;itk::MultiThreader<br> &nbsp;&nbsp;&nbsp;&nbsp;Reference Count: 1<br> &nbsp;&nbsp;&nbsp;&nbsp;Modified Time: 32<br> &nbsp;&nbsp;&nbsp;&nbsp;Debug: Off<br> &nbsp;&nbsp;&nbsp;&nbsp;Observers:<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;none<br> &nbsp;&nbsp;&nbsp;&nbsp;Thread Count: 4<br> &nbsp;&nbsp;&nbsp;&nbsp;Global Maximum Number Of Threads: 128<br> &nbsp;&nbsp;&nbsp;&nbsp;Global Default Number Of Threads: 4<br> &nbsp;&nbsp;Danielson Distance:<br> &nbsp;&nbsp;Input Is Binary &nbsp;&nbsp;: 0<br> &nbsp;&nbsp;Use Image Spacing : 1<br> &nbsp;&nbsp;Squared Distance &nbsp;: 0<br><br>this-&gt;derivedFilter-&gt;GetOutput(0) = 0x26750a0<br>this-&gt;derivedFilter-&gt;GetOutput(1) = 0<br>this-&gt;derivedFilter-&gt;GetOutput(2) = 0<br>this-&gt;derivedFilter-&gt;GetOutput() = 0x26750a0<br>this-&gt;derivedFilter-&gt;GetVoronoiMap() = 0x2674cb0<br>this-&gt;derivedFilter-&gt;GetVectorDistanceMap() = 0x2675480<br>WARNING: In /usr/local/include/ITK-4.1/itkImageSource.hxx, line 112<br>DanielssonDistanceMapImageFilter (0x26707d0): dynamic_cast to output <br>type failed<br><br>WARNING: In /usr/local/include/ITK-4.1/itkImageSource.hxx, line 112<br>DanielssonDistanceMapImageFilter (0x26707d0): dynamic_cast to output <br>type failed<br>&lt;/SCREEN&gt;<br><br><br>Best regards,<br><br>Ramon.<br><br>-- <br>Dr. Ramón Casero Cañas<br><br>Computational Biology<br>Department of Computer Science<br>University of Oxford<br>Wolfson Building, Parks Rd<br>Oxford OX1 3QD<br><br>tlf &nbsp;&nbsp;&nbsp;&nbsp;+44 (0) 1865 610737<br>web &nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas">http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas</a><br>photos &nbsp;<a href="http://www.flickr.com/photos/rcasero/">http://www.flickr.com/photos/rcasero/</a><br>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.php<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></div></blockquote></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p><br class="Apple-interchange-newline"></span></div></span><br class="Apple-interchange-newline">
</div>
<br></div></body></html>