[Insight-users] Error even after fixing ITK bug
/CombiningImageSeriesReader and RawImageIO
Andreas Keil
andreas.keil at cs.tum.edu
Fri Mar 9 18:39:43 EST 2007
Dear all,
sorry for bothering you. I now managed to solve my problem myself. Setting
up the RawImageIO with dimension 2 helps. I did not realize that the IO
format had to be specified for a single file. This also resolves the
supposed bugs which actually were no bugs. The following code works just
fine now:
-------------------------------------------------------------------------
// set up image input using ITK
const unsigned int Dimension = 3;
typedef float PixelType;
typedef itk::Image<PixelType, Dimension> ImageType;
// set up reader
typedef itk::ImageSeriesReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
typedef itk::RawImageIO<PixelType, Dimension-1> ImageIOType;
ImageIOType::Pointer io = ImageIOType::New();
io->SetDimensions(0, 620);
io->SetDimensions(1, 480);
io->SetSpacing(0, 1.0);
io->SetSpacing(1, 1.0);
io->SetOrigin(0, 0.0);
io->SetOrigin(1, 0.0);
io->SetHeaderSize(0);
io->SetByteOrderToLittleEndian();
io->SetFileTypeToBinary();
io->SetFileDimensionality(2);
io->SetPixelType(itk::ImageIOBase::SCALAR);
io->SetNumberOfComponents(1);
typedef itk::NumericSeriesFileNames NameGeneratorType;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat("PIG_205.%03d");
nameGenerator->SetStartIndex(1);
nameGenerator->SetEndIndex(191);
reader->SetImageIO(io);
reader->SetFileNames(nameGenerator->GetFileNames());
// read image into ITK image
reader->Update();
ImageType::Pointer itkImg = ImageType::New();
itkImg = reader->GetOutput();
-------------------------------------------------------------------------
Andreas
More information about the Insight-users
mailing list