[Insight-users] beginner needs help (please)
Alberto Bert
abert at mauriziano . it
Tue, 27 Aug 2002 17:21:43 +0200
Hi all,
I'm trying to understanding something about itk (2 days user.)
I've genarated an image using vtk and now I would like to import it.
I've started watching the SampleProject example, but for me is very hard go further,
without any documentation (but the Doxygen.)
My little program compiles, but when I try to read the image, apparently it waits (obviously something
is wrong :-(
I know that it is a stupid problem for most of you, but for me any help would be very precious, in order
to start to undertand a little of the itk philosofy.
Furthermore, is there some kind of documentation describing the itk general concepts? Or
some repository with a lot of simple examples for itk user?
Tank you very much,
Alberto
Here is the code:
#include <iostream>
#include "itkImage.h"
#include "itkVTKImageIO.h"
int main()
{
const char * in_file = "colmod.vtk";
//allocate image
typedef float PixelType;
typedef itk::Image<PixelType,3> ImageType;
enum { ImageDimension = ImageType::ImageDimension };
ImageType::SizeType size = {{100,100,300}};
ImageType::IndexType index = {{0,0,0}};
ImageType::RegionType region;
region.SetSize( size );
region.SetIndex( index );
ImageType::Pointer vol = ImageType::New();
vol->SetLargestPossibleRegion( region );
vol->SetBufferedRegion( region );
vol->SetRequestedRegion( region );
vol->Allocate();
//read vtk image
itk::VTKImageIO::Pointer read_vtk = itk::VTKImageIO::New();
if(read_vtk->CanReadFile(in_file)) std::cout << in_file << " is readable\n";
else{
std::cout << in_file << " is not readable\n";
return 1;
}
read_vtk->SetFileName(in_file);
read_vtk->Read(vol);
return 0;
}