[vtkusers] xxxxxSPAMxxxxx Re: A series of DICOM images loading

alex alexdowson at hotmail.com
Fri Jul 2 01:30:59 EDT 2010


Hi


If you wish you can  look MITK  project which doing that you want. But project is bigger you have look at code around it. It is opensource and based on VTK and ITK.

http://www.mitk.org/wiki


  ----- Original Message ----- 
  From: Xiaopeng Yang 
  To: vtkusers at vtk.org 
  Sent: Friday, July 02, 2010 10:54 AM
  Subject: [vtkusers] A series of DICOM images loading


  Dear All,

   

  I have succeeded in loading a series of DICOM images and visualized them by VTK. However, I can just see the last DICOM file. What I want is that through controlling the scroll of the mouse, I can navigate from one slice to another slice. Does anybody know how to fulfill the goal?

   

  Attached please find my code.

   

  Thank you.

  Xiaopeng

   

    typedef signed short    PixelType;

    const unsigned int      Dimension = 3;

   

    typedef itk::OrientedImage< 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( "F:/Documents and Settings/Xiaopeng/Desktop/Patient (Pai Sang Pu)/Output/Difussion" );

   

    typedef std::vector< std::string >    SeriesIdContainer;

      

    const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();

      

    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;

    seriesIdentifier = seriesUID.begin()->c_str();

   

    typedef std::vector< std::string >   FileNamesContainer;

    FileNamesContainer fileNames;

   

    fileNames = nameGenerator->GetFileNames( seriesIdentifier );

   

    reader->SetFileNames( fileNames );

   

    typedef itk::ImageToVTKImageFilter<ImageType>FilterType;

    FilterType::Pointer connector = FilterType::New();

   

    try

      {

      reader->Update();

      }

    catch (itk::ExceptionObject &ex)

      {

      std::cout << ex << std::endl;

      return EXIT_FAILURE;

      }

   

    connector->SetInput(reader->GetOutput());

   

    vtkImageViewer *viewer = vtkImageViewer::New();

    vtkRenderWindowInteractor *renderWindowInteractor = vtkRenderWindowInteractor::New();

   

    viewer->SetupInteractor(renderWindowInteractor);

    viewer->SetInput(connector->GetOutput());

    viewer->Render();

    viewer->SetColorWindow(255);

    viewer->SetColorLevel(128);

   

    renderWindowInteractor->Start();



------------------------------------------------------------------------------


  _______________________________________________
  Powered by www.kitware.com

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

  Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

  Follow this link to subscribe/unsubscribe:
  http://www.vtk.org/mailman/listinfo/vtkusers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100702/b5d7e109/attachment.htm>


More information about the vtkusers mailing list