[Insight-users] ImageSeriesReadWrite only reads first file.

Luis Ibanez luis.ibanez at kitware.com
Tue Jun 12 21:28:19 EDT 2007


Hi Emma,

Note that you can directly read in VolView the set of PNG images,
you don't really need to convert them to .vtk.

Simply load one of the .png images, and Volview will offer you
the option of completing the series.

Please let us know if by loading the data in this way, you
get a normal visualization.


    Thanks


       Luis


--------------------
Emma Ryan wrote:
> The files are named as file000.png, file001.png, ...file031.png.
> 
> The .vtk file generated is of a decent size. Also, when I read in the 
> .vtk and write out Image series, using the ImageReadImageSeriesWrite.cpp 
> file,  I can recreate the original 32 2D slices.
> 
> I am simply not able to view them using volview. Any clues !  Volview 
> does ask for Z-spacing and units, but then it displays nothing.
> 
> Emma
> 
> 
> ----- Original Message ----
> From: Andinet Enquobahrie <andinet.enqu at kitware.com>
> To: Emma Ryan <eryanvtk at yahoo.com>
> Sent: Tuesday, June 12, 2007 5:31:13 AM
> Subject: Re: [Insight-users] ImageSeriesReadWrite only reads first file.
> 
> 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"
> 
> 
> How are the png images named? Give us a list of their names... The issue
> might be with the file format..
> 
>  >
>  > 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 
> <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 
> <http://tools.search.yahoo.com/shortcuts/?fr=oni_on_mail&#news>>
>  >
>  >------------------------------------------------------------------------
>  >
>  >_______________________________________________
>  >Insight-users mailing list
>  >Insight-users at itk.org
>  >http://www.itk.org/mailman/listinfo/insight-users
>  >  
>  >
> 
> 
> -- 
> ==========================================================
> Andinet A. Enquobahrie, PhD
> R&D Engineer
> Kitware Inc.
> 
> 28 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-371-3971 x124
> www.kitware.com <http://www.kitware.com>
> 
> 
> 
> 
> ------------------------------------------------------------------------
> Boardwalk for $500? In 2007? Ha!
> Play Monopoly Here and Now 
> <http://us.rd.yahoo.com/evt=48223/*http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow> 
> (it's updated for today's economy) at Yahoo! Games.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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