[Insight-users] Problem Loading an image CT

Luis Ibanez luis . ibanez at kitware . com
Mon, 08 Jul 2002 02:48:09 -0400


Hi Alexandra,


ITK has a mechanism to support reading multiple image file formats.

This mechanism works by providing a front end reader :

the "ImageFileReader" class,

http://public.kitware.com/Insight/Doxygen/html/classitk_1_1ImageFileReader.html

which looks like a filter (an Image Source to be precise).

The actual reading of the image file is delegated to particular
classes implementing specific file formats. Those classes derive
from the ImageIO class. There should be at least one for each
specific file format (e.g. Raw, MetaImage....).

http://public.kitware.com/Insight/Doxygen/html/classitk_1_1ImageIOBase.html

This structure facilitates to produce cleaner code that is almost
independent of the Image file format.

Your code is fine, since you are declaring and instantiating the
ImageFileReader. However, no ImageIO class has been specified.

You just need to add ImageIO Factories using code like:

#include <itkMetaImageIOFactory.h>
#include <itkPNGImageIOFactory.h>
#include <itkRawImageIOFactory.h>


itk::MetaImageIOFactory::RegisterOneFactory();
itk::PNGImageIOFactory::RegisterOneFactory();
itk::RawGImageIOFactory::RegisterOneFactory();


Please take a look at the examples:

    Insight/Examples/RawImageReadWrite
    Insight/Examples/RawImageReaderViewer

that illustrate how to read a Raw Image.
The first example rewrite the image to Raw format.
The second example displays the image slice by slice.


Note that there should be an ImageIO adapted to
your ".dat" image file format. If your ".dat" file
is just a raw file, please use the ".raw" extension
since this is the hint that the factory uses in
order to recognize your raw image file as such.


Please let us know if you encounter any problem
using the ImageIO Factories.


Thanks

   Luis



(We still have some improvements pending on the IO,
that were suggested by users in the mailling list,...
they should be comming soon..)


==================================================

Alexandra La Cruz wrote:

> Hi,
> 
> I tryin to load an image CT, this image can be loaded in other aplication
> using OpenGL. Now I would like to move to use itk library.
> 
> This is the information of file
> Loading Finished: (HOURS:MINUTES:SECONDS): 00:00:07
> Duration in ms: 7703
> Transferrate in MB/s: 8.016357
> 
> xSize: 256, ySize: 256, zSize: 494,   zScale:2.000000
> File read correctly. Init Window handle
> Textursize: 2048
> 
> And I used:
> 
>       typedef itk::Image< char, 3 >    myImageType;
> 	typedef itk::ImageFileReader< myImageType > myImageReader;
> 
> 	myImageReader::Pointer  imageReader = myImageReader::New();
> 
> 	std::cout <<"Getting file"<<std::endl;
> 
> 	imageReader->SetFileName("test.dat");
> 	try{
> 	  	imageReader->Update();
> 	}
> 	catch (itk::ExceptionObject & e)
> 	{
> 		std::cerr << "exception in file reader " << std::endl;
> 		std::cerr << e.GetDescription() << std::endl;
> 		std::cerr << e.GetLocation() << std::endl;
> 		return EXIT_FAILURE;
> 	}
> 	std::cout <<"Done with file"<<std::endl;
> 
> In order to read the file.
> 
> But I have this exception:
> ----
> Getting file
> exception in file reader
>  Could not create IO object for file test.dat
> Unknown
> ----
> 
> 
> Could some one help me? what it is the problem?
> 
> I will thanks your valious help
> 
> Greetings
> ALC
> 
> --------------------------------------------------------------
>                        Alexandra La Cruz
>           Institute of Computer Graphics and Algorithms
>                  Vienna University of Technology
> mailto:alacruz@cg.tuwien.ac.at
> http://www.cg.tuwien.ac.at/staff/AlexandraLaCruz.html
> Tel.: +43 1 58801-18670                 Fax: +43 1 58801-18698
> --------------------------------------------------------------
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 
>