[Insight-users] Re: Error using ImageReader class
Luis Ibanez
luis.ibanez@kitware.com
Mon, 24 Feb 2003 22:45:14 -0500
Hi Neha,
"type_info" should be defined in the std:: namespace
when you enable RTTI (Run Time Type Information)
in the Project Settings menu of VC++.
If you are using CMake for generating your project,
this option should already be enabled. The same goes
for enabling "Exception" handling.
Please go to the "Project Settings" menu, select
the C++ tab and look for the section where RTTI
and Exceptions are selected. Both options should
be already on.
If they are off, something is going wrong with
the CMake configuration.
Another option is that you may be missing one
of the service packs for Visual Studio 6.0.
I think the latest one is Service Pack 5 (SP5).
Please verify which one is the latest service
pack of your VC++ compiler.
-----
The example code that you wrote looks fine.
The only detail is that you don't need to create
the image with "New()" since later you are
getting the image from the reader using the
GetOutput() method.
You could do simply:
ImageType::Pointer image = filter->GetOutput();
Also note that you are defining a 3D image,
but reading a PNG file. PNG files only support
2D images. This current code will read a 2D
image as a single slice of a 3D image. We
call this a degenerated volume. Note that
some filter will miss-behave with such images.
For example any filter requiring a 3D neighborhood
to operate on. (for example, Median filter,
Erosion/Dilation filters...)
-----
Please let us know what you find concerning
the Project settings and the service pack
of your compiler.
Thanks
Luis
-------------------------------
Neha D wrote:
> Hi Luis,
>
> Thanks for your lot of help. I could build my own example program of
> creating image istance, out of ITK source. Error was do to not using
> proper libraries.
>
> Anyway, I am facing problems while using ImageReader class. I have used
> follwoing simple code , which is given in software guide.
>
> -------------------------------------------------------------
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
>
> #include <iostream>
> int main()
> {
> typedef itk::Image< unsigned short, 3 > ImageType;
> ImageType::Pointer image = ImageType::New();
>
> std::cout << "This program read the 2-D PNG image!" << std::endl;
>
> typedef itk::ImageFileReader< ImageType > ReaderType;
> ReaderType::Pointer reader = ReaderType::New();
> const char * filename = "image001.png";
>
> reader->SetFileName( filename ); reader->Update();
> image = reader->GetOutput();
> return 0;
> }
>
> --------------------------------------------------------------
>
> Here again, cmake build is successful, but i get following error in MSVC
> build.
>
> *itkImageIOBase.h*(108) : error C2039: 'type_info' : is not a member of
> 'std'
>
> ---------------------------------------------------------------------------------------------------------------
>
> This can be related to adding include directoried in cmake build. but
> can't figure out exact problem. How can i find out where this variable
> is defined.
>
> Thanks.
>