Take a look at your writerType typedef.<div><br><br><div class="gmail_quote">On Tue, Mar 15, 2011 at 9:49 AM, john smith <span dir="ltr">&lt;<a href="mailto:mkitkinsightuser@gmail.com">mkitkinsightuser@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi to everyone,<br><br>I want to read an image and use a derivative image filter.I wrote the following code, but when I get a failure because I thonk that the types of reader,writer and derivative image filter do not match each other.Could somebody help me?<br>

<br>Thanks in advance<br><br>================DerivativeImageFilter.cxx==========================<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>

#include &quot;itkDerivativeImageFilter.h&quot;<br> <br><br> <br>int main(int argc, char * argv[])<br>{<br>  // Verify command line arguments<br>  if( argc &lt; 2 )<br>    {<br>    std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; inputImageFile&quot; &lt;&lt; std::endl;<br>    return EXIT_FAILURE;<br>    }<br> <br>  // Parse command line arguments<br>  std::string inputFilename = argv[1];<br> <br>  // Setup types<br>

  typedef itk::Image&lt; float,  2 &gt;        FloatImageType;<br>  typedef itk::Image&lt; unsigned char, 2 &gt; UnsignedCharImageType;<br> <br>  typedef itk::ImageFileReader&lt; UnsignedCharImageType &gt;  readerType;<br>

  typedef itk::ImageFileReader&lt; UnsignedCharImageType &gt;  writerType;<br> <br>  typedef itk::DerivativeImageFilter&lt;<br>          UnsignedCharImageType, FloatImageType &gt;  filterType;<br> <br>  // Create and setup a reader<br>

  readerType::Pointer reader = readerType::New();<br>  reader-&gt;SetFileName( inputFilename.c_str() );<br> <br>  // Create and setup a derivative filter<br>  filterType::Pointer derivativeFilter = filterType::New();<br>
  derivativeFilter-&gt;SetInput( reader-&gt;GetOutput() );<br>
  derivativeFilter-&gt;SetDirection(0); // &quot;x&quot; axis<br> <br>   typedef  itk::ImageFileWriter&lt; writerType  &gt; WriterType;<br>  WriterType::Pointer writer = WriterType::New();<br>  writer-&gt;SetFileName(&quot;result.png&quot;);<br>

  writer-&gt;SetInput(derivativeFilter-&gt;GetOutput());<br><br>      try<br>    {<br>    writer-&gt;Update();<br>    }<br>    catch( itk::ExceptionObject exp )<br>    {<br>    std::cerr &lt;&lt; &quot;Exception caught !&quot; &lt;&lt; std::endl;<br>

    std::cerr &lt;&lt; exp &lt;&lt; std::endl;<br>    }<br> <br>  return EXIT_SUCCESS;<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>
<br></blockquote></div><br></div>