[vtkusers] Reading DICOM using vtkImageActor

Sam Raby rabysam28 at gmail.com
Tue Mar 4 13:36:16 EST 2014


Sorry that I did not include the corrected code in the previous email. Here
it is:


    // DICOM Reader

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

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

    reader->Update();

    vtkSmartPointer<vtkImageData> DICOMvtkImageData =
vtkSmartPointer<vtkImageData>::New();

    DICOMvtkImageData->DeepCopy(this->DICOMReader->GetOutput());


    // Mapper

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

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


    // Actor

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

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

    int actorDisplayExtent[6];

    DICOMvtkImageData->GetExtent(actorDisplayExtent);

    mapActor->SetDisplayExtent(actorDisplayExtent[0], actorDisplayExtent[1],

                               actorDisplayExtent[2], actorDisplayExtent[3],

                               desiredSliceIndex, desiredSliceIndex);



On Tue, Mar 4, 2014 at 12:29 PM, Sam Raby <rabysam28 at gmail.com> wrote:

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


More information about the vtkusers mailing list