[Insight-users] Reading a Dicom Series in ITK and visualizing it in VTK

unity csharp developement.unity at gmail.com
Sat Mar 30 19:26:04 EDT 2013


I am relatively new to ITK and VTK.  I am trying to read a DICOM series
into ITK and i want to visualize it with VTK .

the following code  allows  to read a  DICOM series with  success, now i
want to visualize it with vtk

int main( int argc, char* argv[] )
{
typedef unsigned short    PixelType;
  const unsigned int      Dimension = 3;
  typedef itk::Image< PixelType, Dimension >         ImageType;

typedef itk::ImageSeriesReader< ImageType >        ReaderType;
  ReaderType::Pointer reader = ReaderType::New();
 typedef itk::GDCMImageIO       ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  reader->SetImageIO( dicomIO );
  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();
  nameGenerator->SetUseSeriesDetails( true );
  nameGenerator->AddSeriesRestriction("0008|0021" );
  nameGenerator->SetDirectory(
"C:/Lab/VersionEssaies/MCVS2008Test/DICOM/digest_article" );
  try
    {

    typedef std::vector< std::string >    SeriesIdContainer;
    const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
std::cout << seriesUID.size() << std::endl;
    SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
    SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
    while( seriesItr != seriesEnd )
      {
      std::cout << seriesItr->c_str() << std::endl;
      seriesItr++;
    }
    std::string seriesIdentifier;
    if( argc > 3 )
      {
      seriesIdentifier = argv[3];
      }
    else
      {
      seriesIdentifier = seriesUID.begin()->c_str();
           }

std::cout << seriesIdentifier.c_str() << std::endl;

    typedef std::vector< std::string >   FileNamesContainer;
    FileNamesContainer fileNames;
    fileNames = nameGenerator->GetFileNames( seriesIdentifier );
    reader->SetFileNames( fileNames );
   try
     {
     reader->Update();


     }
   catch (itk::ExceptionObject &ex)
     {
      std::cout << ex << std::endl;
      return EXIT_FAILURE;
     }
 }

  catch (itk::ExceptionObject &ex)
    {
    std::cout << ex << std::endl;
    return EXIT_FAILURE;
    }


  return EXIT_SUCCESS;
}

If anyone has an  example that does what i am trying to do
 please let me know. I would really appreciate it.
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130331/52e046e0/attachment.htm>


More information about the Insight-users mailing list