[Insight-users] read raw images
Leila baghdadi
baghdadi at sickkids.ca
Thu Dec 1 13:22:19 EST 2005
well, I think the error is telling you what is going on, the file name
you are providing does not match any of the suffices itk currently has!
if you are trying to read a raw image,
you need to have a tiny text header for it *.mhd (there is a sample file
in itk file format website),
The above file includes the name of the raw file *.raw
Leila
On Thu, 2005-12-01 at 19:15 +0100, 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
--
Leila baghdadi <baghdadi at sickkids.ca>
More information about the Insight-users
mailing list