<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<short,short>, 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<std::size_t R,typename T = short></DIV><DIV>class DicomData :</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>public itk::Image<T,R></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<std::string>& filenames);</DIV><DIV>};</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>template<std::size_t R,typename T></DIV><DIV>DicomData<R,T>::DicomData(const std::vector<std::string>& 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<short,R>::Pointer<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>input_image_ptr = reader->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<itk::Image<short,R>,itk::Image<T,R> ></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->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->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& 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 << "exception in image series reader " << 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 << e << 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->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<class TImage></DIV><DIV>class CastImageFilter<TImage,TImage></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>