[vtkusers] Reading DICOM using vtkImageActor

Sam Raby rabysam28 at gmail.com
Tue Mar 4 12:10:46 EST 2014


Hi,

I am trying to read DICOM series using vtkImageActor. (Note: I know I can
read them easily by vtkImageViewer2, however it is not suitable for my
application).

The problem is when I use SetZSlice, it does not update the slice and it
always shows the first slice of DICOM. I call SetZSlice in both
vtkImageActor and vtkImageMapper but it does not change the slice.

Thanks for any tips, and here is my simple code:

    // DICOM Reader

    vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();

    reader->SetDirectoryName("/home/Images/DICOM");

    reader->Update();


    // Mapper

    vtkSmartPointer<vtkImageMapper> imageMapper =
vtkSmartPointer<vtkImageMapper>::New();

    imageMapper->SetInputData(reader->GetOutput());

    imageMapper->SetZSlice(12); // does not work.


    // Actor

 vtkSmartPointer<vtkImageActor> mapActor = vtkSmartPointer<vtkImageActor>::
New();

    mapActor->SetInputData(imageMapper->GetInput());

    mapActor->SetZSlice(12); // this also does not work.


    // Visualization

    vtkRenderer *ren=vtkRenderer::New();

    ren->AddActor(mapActor);

    ren->ResetCamera();


    vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();

    renderWindow->AddRenderer(ren);


    vtkSmartPointer<vtkRenderWindowInteractor> iren =
vtkSmartPointer<vtkRenderWindowInteractor>::New();

    iren->SetRenderWindow(renderWindow);

    iren->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140304/8e2aeb00/attachment.html>


More information about the vtkusers mailing list