[Insight-users] (no subject)

sami bourouis sami.bourouis at hotmail.com
Thu Dec 14 06:56:44 EST 2006


I'm used this code to generate a 3D file image (sigle file) from series but 
I think that there is prblem with the appropriete type. Which type can I use 
?  AnalyzeImageIO, MetaImageIO, GDCMImageIO, ....

    reader->SetImageIO( itk::AnalyzeImageIO::New() );   !!! ????

the Error is :
Impossible to write !!
Itk::ExceptionObject <011AF4B0>
Location : ”unknown”
File: c:\vtk\lib\Insight26\code\itkAnalyzeImageIO.cxx
Line: 786
Description: itk:ERROR: AnalyzeImageIO<01706720>: File cannot be read


I'm used this code

#include "itkImage.h"
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
#include "itkNumericSeriesFileNames.h"
#include "itkAnalyzeImageIO.h"
#include "itkMetaImageIO.h"


int main( int argc, char ** argv )
{

  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();

  typedef itk::NumericSeriesFileNames    NameGeneratorType;

  NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();

  nameGenerator->SetSeriesFormat("raw%d.tga" );
  nameGenerator->SetStartIndex( 1 );
  nameGenerator->SetEndIndex( 60 );
  nameGenerator->SetIncrementIndex( 1 );

  reader->SetImageIO( itk::AnalyzeImageIO::New() );
  reader->SetFileNames( nameGenerator->GetFileNames()  );

  writer->SetFileName( "volume.hdr");
  writer->SetInput( reader->GetOutput() );
  try
    {
    writer->Update();
    }
  catch( itk::ExceptionObject & err )
    {
    std::cerr << "Impossible to write !!" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
    }

  return EXIT_SUCCESS;
}

_________________________________________________________________
MSN Messenger: appels gratuits de PC à PC ! 
http://www.msn.fr/msger/default.asp



More information about the Insight-users mailing list