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

David Cole dlrdave at aol.com
Sun Mar 31 09:48:38 EDT 2013


This example shows how to visualize an ITK image regardless of its 
source. The input to it is an ITK image. (Which you already have as the 
output of your DICOM reading...)

    http://www.itk.org/Wiki/ITK/Examples/Visualization/QuickView

This stack overflow question, and its answers and the links in the 
answers also provide good tips on how to achieve your goal:

     
http://stackoverflow.com/questions/8576686/how-to-connect-itk-with-vtk


Hope this helps,
David


-----Original Message-----
From: unity csharp <developement.unity at gmail.com>
To: insight-users <insight-users at itk.org>
Sent: Sun, Mar 31, 2013 9:37 am
Subject: [Insight-users] Reading a Dicom Series in ITK and visualizing 
it in VTK



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.




_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users

  


More information about the Insight-users mailing list