<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><div>Hi,<br><br> I am trying to generate a .vtk file (3D ) from a set of .png images. I use the ImageSeriesReadWrite.cxx example provided in ITK as is. My command line syntax is "SeriesRW.exe 0 31 output.vtk" <br><br>i.e SeriesRW is the executable, there are 32 slices starting from 0, and the output format is supposed to be .vtk , so that I can open it using Volview.<br><br>While the program executes with no errors or warnings, when I open output.vtk file in Volview, it seems to be empty.<br><br>I am not sure why this. If anyone has a clue as to why
this happens, please let me know. Here is the code.<br><br>#include "itkImage.h"<br>#include "itkImageSeriesReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkNumericSeriesFileNames.h"<br>#include "itkPNGImageIO.h"<br><br><br>int main( int argc, char ** argv )<br>{<br> <br> if( argc < 4 )<br> {<br> std::cerr << "Usage: " << std::endl;<br> std::cerr << argv[0] << " firstSliceValue lastSliceValue outputImageFile " << std::endl;<br> return EXIT_FAILURE;<br> }<br><br><br> typedef unsigned char PixelType;<br> const unsigned int Dimension = 3;<br><br> typedef itk::Image< PixelType, Dimension > ImageType;<br><br> typedef itk::ImageSeriesReader< ImageType
> ReaderType;<br> typedef itk::ImageFileWriter< ImageType > WriterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> const unsigned int first = atoi( argv[1] );<br> const unsigned int last = atoi( argv[2] );<br><br> const char * outputFilename = argv[3];<br><br><br> typedef itk::NumericSeriesFileNames NameGeneratorType;<br><br> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br><br><br> nameGenerator->SetSeriesFormat( "file%03d.png" );<br><br> nameGenerator->SetStartIndex( first);<br> nameGenerator->SetEndIndex( last );<br> nameGenerator->SetIncrementIndex( 1 );<br><br><br><br> reader->SetImageIO( itk::PNGImageIO::New() );<br><br> reader->SetFileNames( nameGenerator->GetFileNames() );<br><br><br>
writer->SetFileName( outputFilename );<br><br> writer->SetInput( reader->GetOutput() );<br><br> try <br> { <br> writer->Update(); <br> } <br> catch( itk::ExceptionObject & err ) <br> { <br> std::cerr << "ExceptionObject caught !" << std::endl; <br> std::cerr << err << std::endl; <br> return EXIT_FAILURE;<br> } <br><br><br> return EXIT_SUCCESS;<br>}<br><br><br>Thank you,<br>Emma<br></div></div><br>
<hr size="1">Building a website is a piece of cake. <br>Yahoo! Small Business gives you <a rel="nofollow" target="_blank" href="http://us.rd.yahoo.com/evt=48251/*http://smallbusiness.yahoo.com/webhosting/?p=PASSPORTPLUS">all the tools to get online.</a></div><br></div></div><br>
<hr size=1>
Don't get soaked. Take a<a href="
http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news"> quick peak at the forecast </a><br> with the<a href="
http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news">Yahoo! Search weather shortcut.</a></body></html>