<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>&nbsp; I am trying to generate a .vtk file (3D ) from a&nbsp; set of .png images. I use the ImageSeriesReadWrite.cxx example provided in ITK as is. My command line syntax is&nbsp; "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.&nbsp; If anyone has a clue as to why
 this happens, please let me know.&nbsp; 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>&nbsp; <br>&nbsp; if( argc &lt; 4 )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "Usage: " &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; " firstSliceValue lastSliceValue&nbsp; outputImageFile " &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; }<br><br><br>&nbsp; typedef unsigned char&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PixelType;<br>&nbsp; const unsigned int Dimension = 3;<br><br>&nbsp; typedef itk::Image&lt; PixelType, Dimension &gt;&nbsp; ImageType;<br><br>&nbsp; typedef itk::ImageSeriesReader&lt; ImageType
 &gt;&nbsp; ReaderType;<br>&nbsp; typedef itk::ImageFileWriter&lt;&nbsp;&nbsp; ImageType &gt;&nbsp; WriterType;<br><br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; WriterType::Pointer writer = WriterType::New();<br><br>&nbsp; const unsigned int first = atoi( argv[1] );<br>&nbsp; const unsigned int last&nbsp; = atoi( argv[2] );<br><br>&nbsp; const char * outputFilename = argv[3];<br><br><br>&nbsp; typedef itk::NumericSeriesFileNames&nbsp;&nbsp;&nbsp; NameGeneratorType;<br><br>&nbsp; NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br><br><br>&nbsp; nameGenerator-&gt;SetSeriesFormat( "file%03d.png" );<br><br>&nbsp; nameGenerator-&gt;SetStartIndex( first);<br>&nbsp; nameGenerator-&gt;SetEndIndex( last );<br>&nbsp; nameGenerator-&gt;SetIncrementIndex( 1 );<br><br><br><br>&nbsp; reader-&gt;SetImageIO( itk::PNGImageIO::New() );<br><br>&nbsp;reader-&gt;SetFileNames( nameGenerator-&gt;GetFileNames()&nbsp; );<br><br><br>&nbsp;
 writer-&gt;SetFileName( outputFilename );<br><br>&nbsp; writer-&gt;SetInput( reader-&gt;GetOutput() );<br><br>&nbsp; try <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; writer-&gt;Update(); <br>&nbsp;&nbsp;&nbsp; } <br>&nbsp; catch( itk::ExceptionObject &amp; err ) <br>&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; "ExceptionObject caught !" &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; err &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; } <br><br><br>&nbsp; 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>