[vtkusers] DICOM series loading and visulization

Jothy jothybasu at gmail.com
Tue Jul 13 04:53:09 EDT 2010


Use vtkImageViewer2 and use SetSlice to scroll through and
setOrientationToXZ/... to set axial/sag/cor slices.

Jothy

On Tue, Jul 13, 2010 at 4:56 AM, Xiaopeng Yang <yxp233 at postech.ac.kr> wrote:

>  Dear all,
>
>
>
> I am trying to load a series of DICOM images and visualizing them through
> VTK. Although I loaded several files, the VTK just visualized one image.
> What I want is to visualize all of them through VTK, not just one file. It
> is better that if I scroll the mouse wheel, I can review them slice by
> slice. Anyone have the experience of doing this? Could you provide an
> example code?
>
>
>
> Attached is my code:
>
>
>
>   //Define image parameters
>
>   typedef    float    InputPixelType;
>
>   typedef    float    OutputPixelType;
>
>   typedef itk::Image< InputPixelType,  3 >   InputImageType;
>
>   typedef itk::Image< OutputPixelType, 3 >   OutputImageType;
>
>
>
>   // Load DICOM files
>
>   typedef itk::ImageSeriesReader< InputImageType >     ReaderType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>
>   typedef itk::GDCMImageIO                        ImageIOType;
>
>   typedef itk::GDCMSeriesFileNames                NamesGeneratorType;
>
>
>
>   ImageIOType::Pointer gdcmIO = ImageIOType::New();
>
>   NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
>
>
>
>   namesGenerator->SetInputDirectory( "C:/test" );
>
>
>
>   const ReaderType::FileNamesContainer & filenames =
>
>                             namesGenerator->GetInputFileNames();
>
>
>
>   unsigned int numberOfFilenames =  filenames.size();
>
>   std::cout << numberOfFilenames << " images loaded" << std::endl;
>
>   for(unsigned int fni = 0; fni<numberOfFilenames; fni++)
>
>     {
>
>     std::cout << "filename # " << fni << " = ";
>
>     std::cout << filenames[fni] << std::endl;
>
>     }
>
>
>
>   reader->SetImageIO( gdcmIO );
>
>   reader->SetFileNames( filenames );
>
>
>
>   typedef itk::ImageToVTKImageFilter<InputImageType>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();
>
>
>
> return 0;
>
>
>
>
>
> Thank you very much!
>
> Xiaopeng
>
> _______________________________________________
> 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/20100713/512b675e/attachment.htm>


More information about the vtkusers mailing list