[Insight-users] read raw images

camille le men camillelemen at hotmail.com
Thu Dec 1 13:15:21 EST 2005


Hi!
I'm trying to read raw images that are binary images of unsigned short. I 
tried with the following program, but when I execute it, it says it catches 
an exception in the ImageFileReader due to the non existence of m_ImageIO. 
If anyone knows where is the pb...I'd be glad!
thanks!
Cam.
prgrmme:

#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRawImageIO.h"
#include<iostream>
#include "itkImage.h"


int main( int argc, char ** argv )
{
  if( argc < 3 )
    {
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " inputImageFile  outputImageFile " << 
std::endl;
    return EXIT_FAILURE;
    }

  typedef unsigned short      PixelType;
  const   unsigned int        Dimension = 2;
  typedef itk::Image< PixelType, Dimension >    ImageType;

  typedef itk::ImageFileReader< ImageType >  ReaderType;
  typedef itk::ImageFileWriter< ImageType >  WriterType;
  typedef itk::RawImageIO<PixelType,Dimension> ImageIOType;

  ImageIOType::Pointer RawIO = ImageIOType::New();

  ReaderType::Pointer reader = ReaderType::New();
  WriterType::Pointer writer = WriterType::New();
  writer->SetImageIO( RawIO );
  const char * inputFilename  = argv[1];
  const char * outputFilename = argv[2];

  reader->SetFileName( inputFilename  );
  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;
}

error message:

ExceptionObject caught !

itk::ImageFileReaderException (0x80f5b70)
Location: "Unknown"
File: 
/tsi/rigoletto/tulip/kitware/install-linux-3.3/include/InsightToolkit/IO/itkImageFileReader.txx
Line: 114
Description:  Could not create IO object for file part_S1_20001015.raw
  Tried to create one of the following:
    MetaImageIO
    PNGImageIO
    VTKImageIO
    GiplImageIO
    AnalyzeImageIO
    StimulateImageIO
    JPEGImageIO
    TIFFImageIO
    NrrdImageIO
    BMPImageIO
    GDCMImageIO
  You probably failed to set a file suffix, or
    set the suffix to an unsupported type.

_________________________________________________________________
3 XBox 360 à gagner chaque jour avec Magic Search ! 
http://www.magicsearch.fr



More information about the Insight-users mailing list