[Insight-users] Exception of series dcm image write

orientation f fuzengliang435 at gmail.com
Tue Dec 2 03:28:18 EST 2008


hello
I follow the instruction of itk user guide to writer the processed series
images into series dcm images, but exception is thrown out:

Exception thrown while reading the image
itk::exceptionObject [0147F010]
location "unknown"
File: D:\Program
Files\ITK\InsightToolkit\Examples\IO\itkImageSeriesWriter.txx
Line: 314
Description: itk::Error: ImageSeriesWriter<036E0000>::The number of filter
names passed is 21 but 1 were excepted.
(I read 21 slice images)

My code is as follow:
typedef itk::ImageSeriesWriter< ImageType3D, ImageType > WriterType;
 WriterType::Pointer writer = WriterType::New();

 typedef itk::GDCMImageIO ImageIOType;
 ImageIOType::Pointer gdcmImageIO=ImageIOType::New();

 writer->SetImageIO(gdcmImageIO);
 writer->SetInput( SeriesReader->GetOutput() );
 // Connect an observer
 ImageProcessUpdate::Pointer observer = ImageProcessUpdate::New();
 writer->AddObserver( itk::ProgressEvent(), observer );

 typedef itk::NumericSeriesFileNames    NameGeneratorType;

 NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();

 std::string format = "ProcessedImg";
 format += "%03d.";
 format += "dcm";

 nameGenerator->SetSeriesFormat( format.c_str() );

 ImageType3D::ConstPointer inputImage = SeriesReader->GetOutput();
 ImageType3D::RegionType   region     =
inputImage->GetLargestPossibleRegion();
 ImageType3D::IndexType    start      = region.GetIndex();
 ImageType3D::SizeType     size       = region.GetSize();

 const unsigned int firstSlice = start[2];
 const unsigned int lastSlice  = start[2] + size[2] - 1 ;

 nameGenerator->SetStartIndex( firstSlice );
 nameGenerator->SetEndIndex( lastSlice );
 nameGenerator->SetIncrementIndex( 1 );

 writer->SetFileNames( nameGenerator->GetFileNames() );
 try
    {
  writer->Update();
    }
 catch( itk::ExceptionObject & excp )
    {
  std::cerr << "Exception thrown while reading the image" << std::endl;
  std::cerr << excp << std::endl;
    }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20081202/106e3ef8/attachment.htm>


More information about the Insight-users mailing list