[Insight-users] Read DICOM : visualize with VTK

Luis Ibanez luis.ibanez at kitware.com
Thu Sep 14 10:50:14 EDT 2006


Hi Brian,


            Welcome to ITK !


  Please read the ITK Software Guide

           http://www.itk.org/ItkSoftwareGuide.pdf

In particular Chapter Seven "Reading and Writing Images"
in pdf-pages 295-346.

You should first make sure that you are reading the
DICOM images correctly, before you attempt to visualize
them with VTK.

You could easily divide this problem in two pieces:

    1) Open the DICOM files
    2) Visualize a volume with VTK

The solution for (1) is in the example:

     Insight/Examples/IO/
          DicomSeriesReadImageWrite2.cxx


The solution for (2) is in the example:

     InsightApplications/Auxiliary/vtk/
                itkReadITKImageShowVTK.cxx




You should first verify that you can use these two
examples independently, (e.g. by writing your DICOM
series as an Analyze of MetaImage file, and then
opening with the visualization program).

Once you get those to work independently, you will
be ready for putting them together in a single piece
of code.


    Regards,


       Luis




==========================
Brian Chacko wrote:
> Hello,
>  
> I am a beginner in ITK toolkit. Could someone tell me how to take DICOM 
> images as input and view it through VTK. The could below is what i have 
> used. But somehow the image is not read and a windows error comes as
> " **
> *
> program.exe has encountered a problem and needs to close. We are sorry 
> for the inconvenience.
> *
> "
> The next error is "Debug assertion failed...." . Is the code written 
> below right??
>  
> # include "itkImage.h"
> # include "itkImageFileReader.h"
> # include "itkImageToVTKImageFilter.h"
> # include "vtkImageViewer.h"
> # include "vtkRenderWindowInteractor.h"
> # include "itkGDCMImageIO.h"
> int main(int argc, char **argv)
> {
>   typedef itk::Image<unsigned short,2> ImageType;
>   typedef itk::ImageFileReader<ImageType> ReaderType;
>   typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
>  
>   ReaderType::Pointer reader = ReaderType::New();
>   ConnectorType::Pointer connector = ConnectorType::New();
>  
>   reader->SetFileName(argv[1]);
>   typedef itk::GDCMImageIO ImageIOType;
>   ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
>   reader->SetImageIO(gdcmImageIO);
>   try
>   {
>    reader->Update();
>   }
>   catch(itk::ExceptionObject & e)
>   {
>    std::cerr <<"exception in file reader "<<std::endl;
>    std::cerr<<e<<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;
>   
> }
>  
>  
> Thanks,
> Brian
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail. 
> <http://us.rd.yahoo.com/evt=42297/*http://advision.webevents.yahoo.com/mailbeta> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> 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