[Insight-users] Problem with DICOM writing
Markus Weigert
m.weigert at fz-juelich.de
Tue Sep 20 04:23:46 EDT 2005
Hi insight-users,
I have a problem with writing Dicom files after reading
a serie to an image and performing a resampling on the Image.
After the image is resampled, by decreasing resolution
of a factor of 1/2 for example, I write the serie out.
However, when I read the written serie and render it with
GLSliceView class e.g., it shows two small images side by side
and the rest of the image is grey.
I may have missed to set some parameters for the output,
but I can't determine which.
Can somebody please give me an advice, how to solve this problem.
Best regards,
Markus
PS:
Writing code is as follows:
//Write DICOM Series
if(imageExtension =="dcm")
{
typedef itk::Image<PixelType,2> Image2DType;
typedef itk::ImageSeriesWriter< ImageType, Image2DType > SeriesWriterType;
typedef itk::NumericSeriesFileNames NameGeneratorType;
std::string format = filename + std::string("%03d") + std::string(".dcm");
SeriesWriterType::Pointer swriter = SeriesWriterType::New();
movingImage->Update();
swriter->SetInput( movingImage );
swriter->SetImageIO( m_gdcmIO ); //DICOM imageIO used for reading
NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
ImageType::RegionType region = movingImage->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;
nameGenerator->SetStartIndex(firstSlice);
nameGenerator->SetEndIndex(lastSlice);
nameGenerator->SetIncrementIndex(1);
nameGenerator->SetSeriesFormat(format.c_str());
swriter->SetFileNames( nameGenerator->GetFileNames() );
m_seriesFileNames->SetOutputDirectory(directory.c_str());
swriter->SetMetaDataDictionaryArray( m_fileSeriesReader->GetMetaDataDictionaryArray() ); //FileSeriesReader which was used for reading
// Try to write the serie:
try
{
swriter->Update();
}
catch( itk::ExceptionObject & excp )
{
std::cerr << "Exception thrown while writing the series " << std::endl;
std::cerr << excp << std::endl;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20050920/22dce74c/attachment.htm
More information about the Insight-users
mailing list