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"><<a href="mailto:mkitkinsightuser@gmail.com">mkitkinsightuser@gmail.com</a>></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 "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>
#include "itkDerivativeImageFilter.h"<br> <br><br> <br>int main(int argc, char * argv[])<br>{<br> // Verify command line arguments<br> if( argc < 2 )<br> {<br> std::cerr << "Usage: " << std::endl;<br>
std::cerr << argv[0] << " inputImageFile" << 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< float, 2 > FloatImageType;<br> typedef itk::Image< unsigned char, 2 > UnsignedCharImageType;<br> <br> typedef itk::ImageFileReader< UnsignedCharImageType > readerType;<br>
typedef itk::ImageFileReader< UnsignedCharImageType > writerType;<br> <br> typedef itk::DerivativeImageFilter<<br> UnsignedCharImageType, FloatImageType > filterType;<br> <br> // Create and setup a reader<br>
readerType::Pointer reader = readerType::New();<br> reader->SetFileName( inputFilename.c_str() );<br> <br> // Create and setup a derivative filter<br> filterType::Pointer derivativeFilter = filterType::New();<br>
derivativeFilter->SetInput( reader->GetOutput() );<br>
derivativeFilter->SetDirection(0); // "x" axis<br> <br> typedef itk::ImageFileWriter< writerType > WriterType;<br> WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName("result.png");<br>
writer->SetInput(derivativeFilter->GetOutput());<br><br> try<br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject exp )<br> {<br> std::cerr << "Exception caught !" << std::endl;<br>
std::cerr << exp << 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>