[Insight-users] ImageSeriesReadWrite only reads first file.

Luis Ibanez luis.ibanez at kitware.com
Tue Jun 12 21:25:27 EDT 2007


Hi Emma,

Your code looks fine.


Could you please do the following ?

A) Post the mailing list the actual set of filenames
    in your directory.


B) Print out the filenames that are generated by
    the NumericSeriesFileNames class.

    you can use code, something like:

  typedef std::vector< std::string >  containerType;

  containerType names = nameGenerator->GetFileNames();

  containerType::const_iterator itr = names.begin();

  while( itr != names.end() )
    {
    std::cout << *itr << std::endl;
    ++itr;
    }



Please post to the list what you find for (A) and (B)


    Thanks


       Luis


------------------
Emma Ryan wrote:
> 
> 
> Hi,
> 
>   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"
> 
> 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.
> 
> While the program executes with no errors or warnings, when I open 
> output.vtk file in Volview, it seems to be empty.
> 
> I am not sure why this.  If anyone has a clue as to why this happens, 
> please let me know.  Here is the code.
> 
> #include "itkImage.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNumericSeriesFileNames.h"
> #include "itkPNGImageIO.h"
> 
> 
> int main( int argc, char ** argv )
> {
>  
>   if( argc < 4 )
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << " firstSliceValue lastSliceValue  
> outputImageFile " << std::endl;
>     return EXIT_FAILURE;
>     }
> 
> 
>   typedef unsigned char                       PixelType;
>   const unsigned int Dimension = 3;
> 
>   typedef itk::Image< PixelType, Dimension >  ImageType;
> 
>   typedef itk::ImageSeriesReader< ImageType >  ReaderType;
>   typedef itk::ImageFileWriter<   ImageType >  WriterType;
> 
>   ReaderType::Pointer reader = ReaderType::New();
>   WriterType::Pointer writer = WriterType::New();
> 
>   const unsigned int first = atoi( argv[1] );
>   const unsigned int last  = atoi( argv[2] );
> 
>   const char * outputFilename = argv[3];
> 
> 
>   typedef itk::NumericSeriesFileNames    NameGeneratorType;
> 
>   NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
> 
> 
>   nameGenerator->SetSeriesFormat( "file%03d.png" );
> 
>   nameGenerator->SetStartIndex( first);
>   nameGenerator->SetEndIndex( last );
>   nameGenerator->SetIncrementIndex( 1 );
> 
> 
> 
>   reader->SetImageIO( itk::PNGImageIO::New() );
> 
>  reader->SetFileNames( nameGenerator->GetFileNames()  );
> 
> 
>   writer->SetFileName( outputFilename );
> 
>   writer->SetInput( reader->GetOutput() );
> 
>   try
>     {
>     writer->Update();
>     }
>   catch( itk::ExceptionObject & err )
>     {
>     std::cerr << "ExceptionObject caught !" << std::endl;
>     std::cerr << err << std::endl;
>     return EXIT_FAILURE;
>     }
> 
> 
>   return EXIT_SUCCESS;
> }
> 
> 
> Thank you,
> Emma
> 
> ------------------------------------------------------------------------
> Building a website is a piece of cake.
> Yahoo! Small Business gives you all the tools to get online. 
> <http://us.rd.yahoo.com/evt=48251/*http://smallbusiness.yahoo.com/webhosting/?p=PASSPORTPLUS>
> 
> 
> ------------------------------------------------------------------------
> Don't get soaked. Take a quick peak at the forecast 
> <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>
> with theYahoo! Search weather shortcut. 
> <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>
> 
> 
> ------------------------------------------------------------------------
> Got a little couch potato?
> Check out fun summer activities for kids. 
> <http://us.rd.yahoo.com/evt=48248/*http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users


More information about the Insight-users mailing list