[Insight-users] Problem with DICOM writing

Luis Ibanez luis.ibanez at kitware.com
Wed Sep 28 14:05:30 EDT 2005


Hi Markus,


It doesn't seem that your problem is on the DICOM writing
but rather on the resampling.


Can you please save the resampled image using another
file format (not DICOM)  ?

for example MetaImage, with the itk::ImageFileWriter...

then look at the saved resampled image and check if it
looks the same as what you get with the DICOM writing.


If so... then the problem is in your resampling code, and
we will need to look at your source code. Please post that
code to the list, and *PLEASE* make sure that you include
the declarations of the pixel types.

[Posting a screenshot of what you see with GLSliceViewer
  will also help us to figure out what may be going wrong.]


A common reason of these two-images view is when there is
a mix of 8-bits and 16-bits pixels types.



     Thanks


        Luis



--------------------------
Markus Weigert wrote:
> 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;
>     }
>  
>  }
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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