[vtkusers] vtkImageViewer2, image disappearing with slice adjustment
Miller, James V (Research)
millerjv at crd.ge.com
Tue Apr 1 09:30:23 EST 2003
I have been using vtkImageViewer2 for most of my image viewing needs for
maybe the last year or so. I like vtkImageViewer2 because I can zoom into
the image and I can easily add geometry to scene using
viewer->SetInput( myImage );
viewer->GetRenderer()->AddActor( myActor );
This is nice when I want to "draw" on top of an image. For instance, I can
construct a PolyData of "edges" and draw them on top of an image. Or I can
highlight sections of an image, etc.
But when I use vtkImageViewer2 to display slices from a volume, I hit upon a
problem. I could only look at the first few slices of volume. After the
first few slices, the image would always be black. My first thought was
this was an "extent" problem with the viewer, but digging through the code,
everything checked out.
vtkImageViewer2 uses the 3D rendering/texture mapping engine to draw a slice
onto a plane. It turns out that the location of that plane is based on the
"z-coordinate" of the slice. As you adjust the slice that is viewed, the
plane moves and eventually gets outside the camera clipping range.
I am not sure whether this really a bug or not. If you are mixing the image
with 3D geometry, I think you want the z-coordinate of the plane to be
adjusted as you switch slices. This way the image can "hide" the portions
of the geometry that is behind it. There are other ways to do this now using
the ImagePlaneWidgets but ImageViewer2 is a quick and dirty solution,
especially if you want to restrict the view to be down the z-axis.
vtkImageViewer2 is confusing, however, when just using the viewer to look at
each slice in the volume. I post this message here because I think google
will index this message so other people can find the solution.
The solution is rather easy. Whenever you call SetZSlice on the viewer, you
need to reset the camera clipping range.
viewer->SetZSlice( slice );
That is all there is to that.
Visualization & Computer Vision
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301
millerjv at research.ge.com <mailto:millerjv at research.ge.com>
james.miller at research.ge.com
(518) 387-4005, Dial Comm: 8*833-4005,
Cell: (518) 505-7065, Fax: (518) 387-6981
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office"
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers