[Insight-users] (no subject)

Brian Chacko brianchacko at yahoo.com
Thu Sep 7 03:11:02 EDT 2006


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20060907/51d4b02a/attachment.htm


More information about the Insight-users mailing list