<div>hello</div>
<div>I follow the instruction of itk user guide to writer the processed series images into series dcm images, but exception is thrown out:</div>
<div> </div>
<div>Exception thrown while reading the image</div>
<div>itk::exceptionObject [0147F010]</div>
<div>location "unknown"</div>
<div>File: D:\Program Files\ITK\InsightToolkit\Examples\IO\itkImageSeriesWriter.txx</div>
<div>Line: 314</div>
<div>Description: itk::Error: ImageSeriesWriter<036E0000>::The number of filter names passed is 21 but 1 were excepted.</div>
<div>(I read 21 slice images)</div>
<div> </div>
<div>My code is as follow:</div>
<div>typedef itk::ImageSeriesWriter< ImageType3D, ImageType > WriterType;<br> WriterType::Pointer writer = WriterType::New();<br> <br> typedef itk::GDCMImageIO ImageIOType;<br> ImageIOType::Pointer gdcmImageIO=ImageIOType::New();<br>
<br> writer->SetImageIO(gdcmImageIO);<br> writer->SetInput( SeriesReader->GetOutput() ); <br> // Connect an observer<br> ImageProcessUpdate::Pointer observer = ImageProcessUpdate::New();<br> writer->AddObserver( itk::ProgressEvent(), observer );<br>
<br> typedef itk::NumericSeriesFileNames NameGeneratorType;<br> <br> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();<br> <br> std::string format = "ProcessedImg";<br> format += "%03d.";<br>
format += "dcm"; <br> <br> nameGenerator->SetSeriesFormat( format.c_str() );<br> <br> ImageType3D::ConstPointer inputImage = SeriesReader->GetOutput();<br> ImageType3D::RegionType region = inputImage->GetLargestPossibleRegion();<br>
ImageType3D::IndexType start = region.GetIndex(); <br> ImageType3D::SizeType size = region.GetSize(); <br> <br> const unsigned int firstSlice = start[2];<br> const unsigned int lastSlice = start[2] + size[2] - 1 ;<br>
<br> nameGenerator->SetStartIndex( firstSlice );<br> nameGenerator->SetEndIndex( lastSlice );<br> nameGenerator->SetIncrementIndex( 1 );<br> <br> writer->SetFileNames( nameGenerator->GetFileNames() );<br> try<br>
{<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excp )<br> {<br> std::cerr << "Exception thrown while reading the image" << std::endl;<br> std::cerr << excp << std::endl;<br>
}</div>