[Insight-users] How to show dicoms with vtk (ImageToVTKImageFilter)

soheilghafurian soheilghafurian at yahoo.com
Mon Jul 18 11:08:43 EDT 2011


Thank you very much, I tried to use your code, but it seems I'm doing
something wrong here. I get this error at line 
color->SetInputConnection(connector->GetOutput());

could you do me a favor and tell me what I'm doing wrong here? the new code
is:

int main()
{ 
	char *fName = fl_file_chooser("Pick the fixed dicom Image", "*.dcm", ".");
      if(fName == NULL) return 0;

  typedef itk::Image< itk::RGBPixel<unsigned char>, 2> ImageType;
  typedef itk::ImageFileReader<ImageType>             ReaderType;
  typedef itk::ImageToVTKImageFilter<ImageType>       ConnectorType;
 
  ReaderType::Pointer reader = ReaderType::New();
  ConnectorType::Pointer connector = ConnectorType::New();
 
  reader->SetFileName(fName);
  reader->Update();
  connector->SetInput(reader->GetOutput());

  vtkSmartPointer<vtkLookupTable> table =
           vtkSmartPointer<vtkLookupTable>::New();
         table->SetRange(-600,900); // image intensity range
         table->SetValueRange(0.0, 1.0); // from black to white
         table->SetSaturationRange(0.0, 0.0); // no color saturation
         table->SetRampToLinear();
         table->Build();
         // Map the image through the lookup table
  vtkSmartPointer<vtkImageMapToColors> color =
           vtkSmartPointer<vtkImageMapToColors>::New();
         color->SetLookupTable(table);
         color->SetInputConnection(connector->GetOutput());
  





 
  vtkSmartPointer<vtkImageActor> actor =
    vtkSmartPointer<vtkImageActor>::New();
  actor->SetInput(color->GetOutput());
 
  vtkSmartPointer<vtkRenderer> renderer =
    vtkSmartPointer<vtkRenderer>::New();
  renderer->AddActor(actor);
  renderer->ResetCamera();
 
  vtkSmartPointer<vtkRenderWindow> renderWindow =
    vtkSmartPointer<vtkRenderWindow>::New();
  renderWindow->AddRenderer(renderer);
 
  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
    vtkSmartPointer<vtkRenderWindowInteractor>::New();
  vtkSmartPointer<vtkInteractorStyleImage> style =
    vtkSmartPointer<vtkInteractorStyleImage>::New();
 
  renderWindowInteractor->SetInteractorStyle(style);
 
  renderWindowInteractor->SetRenderWindow(renderWindow);
  renderWindowInteractor->Initialize();
 
  renderWindowInteractor->Start();
 
  return EXIT_SUCCESS;
}



--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/How-to-show-dicoms-with-vtk-ImageToVTKImageFilter-tp6593222p6595116.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list