[Insight-users] Exception of series dcm image write
Bill Lorensen
bill.lorensen at gmail.com
Tue Dec 2 07:56:41 EST 2008
Please report the typedef's for
ImageType3D and ImageType.
On Tue, Dec 2, 2008 at 3:28 AM, orientation f <fuzengliang435 at gmail.com> wrote:
> 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;
> }
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list