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

Jothy jothybasu at gmail.com
Mon Jul 18 11:18:00 EDT 2011


Try

color->SetInputConnection(connector->GetOutput*Port*());

Jothy

On Mon, Jul 18, 2011 at 4:08 PM, soheilghafurian
<soheilghafurian at yahoo.com>wrote:

> 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.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110718/8db4baec/attachment.htm>


More information about the Insight-users mailing list