<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Taking a quick look at the code, it appears that there is not a do-nothing specialization for <BR><DIV>CastImageFilter in the case that the input and output image types are degenerate; this means</DIV><DIV>that a bunch of unnecessary work gets done if you call CastImageFilter&lt;short,short&gt;, for </DIV><DIV>example. Why, you ask, would you do something like that? Consider a generic class for </DIV><DIV>reading in DICOM data and, possibly converting it to another type via casting:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>template&lt;std::size_t R,typename T = short&gt;</DIV><DIV>class DicomData :</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>public itk::Image&lt;T,R&gt;</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>public: </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>DicomData(const std::vector&lt;std::string&gt;&amp; filenames);</DIV><DIV>};</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>template&lt;std::size_t R,typename T&gt;</DIV><DIV>DicomData&lt;R,T&gt;::DicomData(const std::vector&lt;std::string&gt;&amp; filenames)</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>// use ImageSeriesReader to read DICOM data</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>itk::Image&lt;short,R&gt;::Pointer<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>input_image_ptr = reader-&gt;GetOutput();</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">typedef itk::CastImageFilter&lt;itk::Image&lt;short,R&gt;,itk::Image&lt;T,R&gt; &gt;</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">cast_image_filter_type;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">typedef typename cast_image_filter_type::Pointer</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN><FONT class="Apple-style-span" color="#000000">cast_image_filter_pointer_type;</FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><BR class="khtml-block-placeholder"></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">cast_image_filter_pointer_type</FONT><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">caster = cast_image_filter_type::New();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 10px/normal Monaco; min-height: 14px; "><FONT class="Apple-style-span" color="#000000"><FONT class="Apple-style-span" face="Helvetica" size="3"><SPAN class="Apple-style-span" style="font-size: 12px;"><BR></SPAN></FONT></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">caster-&gt;SetInput(input_image_ptr);</FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><BR class="khtml-block-placeholder"></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">try</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">{</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">                </SPAN>// if T == short, this should do nothing, but it doesn't (do nothing)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">caster-&gt;Update();</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">}</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">catch (itk::ExceptionObject&amp; e)</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">{</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">std::cerr &lt;&lt; "exception in image series reader " &lt;&lt; std::endl;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">std::cerr &lt;&lt; e &lt;&lt; std::endl;</FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><BR class="khtml-block-placeholder"></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">throw;</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">}</FONT></DIV><P style="margin: 0.0px 0.0px 0.0px 0.0px; min-height: 14.0px"><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000"><BR class="khtml-block-placeholder"></FONT></P><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><FONT class="Apple-style-span" color="#000000">image_pointer_type</FONT><FONT class="Apple-style-span" color="#000000">::operator</FONT><FONT class="Apple-style-span" color="#000000">=(caster-&gt;GetOutput());</FONT></DIV><DIV><FONT class="Apple-style-span" color="#000000">}</FONT></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Really, all that is needed is a template specialization in CastImageFilter like this:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>template&lt;class TImage&gt;</DIV><DIV>class CastImageFilter&lt;TImage,TImage&gt;</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>// don't do anything, just return the input pointer...</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Is there some reason why this isn't done? Maybe I'm missing some subtlety that precludes this...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Matthias</DIV></BODY></HTML>