[Insight-developers] itkImageSeriesReader Bug (contd.)
Hauke Heibel
heibel at cs.tum.edu
Tue Oct 23 05:36:39 EDT 2007
Skipped content of type multipart/alternative-------------- next part --------------
#include "itkImageSeriesReader.h"
#include "itkImageFileWriter.h"
using namespace itk;
int main(int argc, char* argv[])
{
const std::string tempDir(argv[1]);
typedef Image<unsigned char, 3> ImageType;
typedef ImageFileWriter<ImageType> FileWriter;
typedef ImageSeriesReader<ImageType> SeriesReaderType;
ImageType::IndexType index = {0, 0, 0};
ImageType::SizeType sizeOne = {320, 240, 5};
ImageType::SizeType sizeTwo = {320, 240, 2};
ImageType::RegionType regionOne(index, sizeOne);
ImageType::RegionType regionTwo(index, sizeTwo);
ImageType::Pointer volumeOne = ImageType::New();
volumeOne->SetRegions(regionOne);
volumeOne->Allocate();
volumeOne->FillBuffer(1);
ImageType::Pointer volumeTwo = ImageType::New();
volumeTwo->SetRegions(regionTwo);
volumeTwo->Allocate();
volumeTwo->FillBuffer(2);
std::vector<std::string> fileNames;
fileNames.push_back(tempDir + "/file1.dcm");
fileNames.push_back(tempDir + "/file2.dcm");
FileWriter::Pointer writer = FileWriter::New();
writer->SetFileName(fileNames[0]);
writer->SetInput(volumeOne);
writer->Update();
writer->SetFileName(fileNames[1]);
writer->SetInput(volumeTwo);
writer->Update();
SeriesReaderType::Pointer seriesReader = SeriesReaderType::New();
seriesReader->SetFileNames(fileNames);
try
{
seriesReader->Update();
}
catch (ExceptionObject& e)
{
std::cout << "The expected exception:" << std::endl;
std::cout << e.what() << std::endl;
}
}
More information about the Insight-developers
mailing list