[vtkusers] Reading DICOM using vtkImageActor

Sam Raby rabysam28 at gmail.com
Tue Mar 4 13:29:51 EST 2014


I learnt that this seems to be a bug as reported here:

http://www.paraview.org/Bug/bug_relationship_graph.php?bug_id=3661&graph=dependency

>From the link, I figured we can get around this issue by
using GetDisplayExtent. So the following code works:

    // 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.



On Tue, Mar 4, 2014 at 11:10 AM, Sam Raby <rabysam28 at gmail.com> wrote:

> 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/bd1d809e/attachment.html>


More information about the vtkusers mailing list