SPAM: [Insight-users] read raw images

Julien Jomier jjomier at cs.unc.edu
Thu Dec 1 16:00:29 EST 2005


Hi Camille,

It seems that you are only setting the RawImageIO for the writer and not 
the reader. Also you need to provide more information, i.e size of the 
image otherwise ITK won't be able to guess it.

You can take a look at the 
Insight\Testing\Code\IO\itkRawImageIOTestX.cxx file for more information.

Hope that helps,

Julien

camille le men wrote:
> 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
> 
> _______________________________________________
> 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