[Insight-users] Help on writing series
Riccio Giancarlo
riccio.giancarlo at gmail.com
Tue Jun 13 05:23:48 EDT 2006
hi to all,
I must write a procedure that takes in income a series (or a single image)
of images and it save them on disc and I have used the following code,
typedef itk::Image < unsigned char, 2 > Image2DType;
typedef itk::ImageSeriesWriter < ImageType, Image2DType > WriterType;
typedef itk::NumericSeriesFileNames NameGeneratorType;
itksys::SystemTools::MakeDirectory( cartella.c_str() );
std::string format = cartella;
format += "\\";
format += nomeFile;
format += "%03d.dcm";
ImageType::ConstPointer inputImage = getItkVtkData()->getItkImage();
ImageType::RegionType region = inputImage->GetLargestPossibleRegion();
ImageType::IndexType start = region.GetIndex();
ImageType::SizeType size = region.GetSize();
const unsigned int firstSlice = start[2];
const unsigned int lastSlice = start[2] + size[2] - 1;
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
nameGenerator->SetSeriesFormat( format.c_str() );
nameGenerator->SetStartIndex( firstSlice );
nameGenerator->SetEndIndex( lastSlice );
nameGenerator->SetIncrementIndex( 1 );
WriterType::Pointer writer = WriterType::New();
writer->SetFileNames( nameGenerator->GetFileNames() );
writer->SetInput( inputImage );
try {
writer->Update();
}
catch( itk::ExceptionObject & excp ) {
std::cerr << excp << std::endl;
}
however it does not work and it places in escape the eguente exception:
"itk::ERROR: ImageSeriesWriter(0A05BCB8): The number of filenames passed is
15 but 1 were expected"
If someone has some suggestion I accept.
thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060613/964de312/attachment.htm
More information about the Insight-users
mailing list