[vtkusers] displaying 2d image using vtkImageActor

Greg Book gbook at gbook.org
Thu Jun 25 14:37:16 EDT 2009


I'm trying to display a 2d image (resliced output from vtkImagePlaneWidget)
onto a separate renderer. I'm able to display the actor, but the image isn't
centered, and the zoom isn't correct.

Here is the code that creates the image actor and displays it:

    vtkImageMapToColors* colorMapY = vtkImageMapToColors::New();
    colorMapY->PassAlphaToOutputOff();
    colorMapY->SetActiveComponent(0);
    colorMapY->SetOutputFormatToLuminance();
    colorMapY->SetInput(planeWidgetY->GetResliceOutput());
    colorMapY->SetLookupTable(planeWidgetY->GetLookupTable());
    vtkImageActor* imageActorY = vtkImageActor::New();
    imageActorY->SetScaleSetInput(colorMapY->GetOutput());

    ren3->AddActor(imageActorY);
    ren3->SetBackground( 0.2, 0.2, 0.2);
    ren3->SetViewport(0.7, 0.33, 1.0, 0.67);
    ren3->GetActiveCamera()->ParallelProjectionOn();
    ren3->GetActiveCamera()->Zoom(0.005);

For some reason if I use the default zoom, the image is zoomed so far in
that I see individual pixels, so I use a zoom of 0.005. With a tiny zoom, I
can see the image, but again, its not centered. I can't seem to find out the
size of the displayed image so that I can center it.

I've tried the vtkImageViewer and it displays correctly, but it makes the
application incredibly slow. How can I center and correctly zoom into the 2d
image?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090625/e2757707/attachment.htm>


More information about the vtkusers mailing list