Looks like concept checking for DerivativeImageFilter. The output image type likely needs to be signed. <div><br><div class="gmail_quote">On Wed, Mar 16, 2011 at 1:59 PM, 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;">and here is my code (if this could help you):<br>\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\<div class="im"><br><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></div> typedef itk::Image< unsigned char, 2 > ImageType;<br> <br> typedef itk::ImageFileReader< ImageType > readerType;<br> typedef itk::ImageFileWriter< ImageType > writerType;<br>
<br> typedef itk::DerivativeImageFilter<<br> ImageType, ImageType > filterType;<div class="im"><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><br></div><div class="im"> 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></div><div><div></div><div class="h5"><div class="gmail_quote">2011/3/16 john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Hi,<br><br>I made thechanges and when I run it from the command line window I get a message which is says that png supports unsigned char and unsigned short. But when I make these changes I get failures in the building of the project:<br>
<i>error C2440: 'initializing' : cannot convert from 'itk::Concept::Detail::UniqueType_bool<__formal>' to 'itk::Concept::Detail::UniqueType_bool<__formal>'. </i>Could somebody help me with this?<br>
<br>Thanks in advance<div><div></div><div><br><br><br><div class="gmail_quote">2011/3/15 robert tamburo <span dir="ltr"><<a href="mailto:robert.tamburo@gmail.com" target="_blank">robert.tamburo@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
Take a look at your writerType typedef.<div><br><br><div class="gmail_quote"><div><div></div><div>On Tue, Mar 15, 2011 at 9:49 AM, john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex"><div><div></div><div>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></div></div>_____________________________________<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>
</blockquote></div><br><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">
</div>
</div></div></blockquote></div><br><div style="padding:0px;margin-left:0px;margin-top:0px;overflow:hidden;word-wrap:break-word;color:black;font-size:10px;text-align:left;line-height:130%">
</div>
</div></div></blockquote></div><br></div>