FreeMat
vtkImageViewer2

Section: Visualization Toolkit Rendering Classes

Usage

vtkImageViewer2 is a convenience class for displaying a 2D image. It packages up the functionality found in vtkRenderWindow, vtkRenderer, vtkImageActor and vtkImageMapToWindowLevelColors into a single easy to use class. This class also creates an image interactor style (vtkInteractorStyleImage) that allows zooming and panning of images, and supports interactive window/level operations on the image. Note that vtkImageViewer2 is simply a wrapper around these classes.

vtkImageViewer2 uses the 3D rendering and texture mapping engine to draw an image on a plane. This allows for rapid rendering, zooming, and panning. The image is placed in the 3D scene at a depth based on the z-coordinate of the particular image slice. Each call to SetSlice() changes the image data (slice) displayed AND changes the depth of the displayed slice in the 3D scene. This can be controlled by the AutoAdjustCameraClippingRange ivar of the InteractorStyle member.

It is possible to mix images and geometry, using the methods:

viewer->SetInput( myImage ); viewer->GetRenderer()->AddActor( myActor );

This can be used to annotate an image with a PolyData of "edges" or or highlight sections of an image or display a 3D isosurface with a slice from the volume, etc. Any portions of your geometry that are in front of the displayed slice will be visible; any portions of your geometry that are behind the displayed slice will be obscured. A more general framework (with respect to viewing direction) for achieving this effect is provided by the vtkImagePlaneWidget .

Note that pressing 'r' will reset the window/level and pressing shift+'r' or control+'r' will reset the camera.

To create an instance of class vtkImageViewer2, simply invoke its constructor as follows

  obj = vtkImageViewer2

Methods

The class vtkImageViewer2 has several methods that can be used. They are listed below. Note that the documentation is translated automatically from the VTK sources, and may not be completely intelligible. When in doubt, consult the VTK website. In the methods listed below, obj is an instance of the vtkImageViewer2 class.

  • string = obj.GetClassName ()
  • int = obj.IsA (string name)
  • vtkImageViewer2 = obj.NewInstance ()
  • vtkImageViewer2 = obj.SafeDownCast (vtkObject o)
  • string = obj.GetWindowName () - Get the name of rendering window.
  • obj.Render (void ) - Render the resulting image.
  • obj.SetInput (vtkImageData in) - Set/Get the input image to the viewer.
  • vtkImageData = obj.GetInput () - Set/Get the input image to the viewer.
  • obj.SetInputConnection (vtkAlgorithmOutput input) - Set/Get the input image to the viewer.
  • int = obj.GetSliceOrientation () - Set/get the slice orientation
  • obj.SetSliceOrientation (int orientation) - Set/get the slice orientation
  • obj.SetSliceOrientationToXY () - Set/get the slice orientation
  • obj.SetSliceOrientationToYZ () - Set/get the slice orientation
  • obj.SetSliceOrientationToXZ () - Set/get the slice orientation
  • int = obj.GetSlice () - Set/Get the current slice to display (depending on the orientation this can be in X, Y or Z).
  • obj.SetSlice (int s) - Set/Get the current slice to display (depending on the orientation this can be in X, Y or Z).
  • obj.UpdateDisplayExtent () - Update the display extent manually so that the proper slice for the given orientation is displayed. It will also try to set a reasonable camera clipping range. This method is called automatically when the Input is changed, but most of the time the input of this class is likely to remain the same, i.e. connected to the output of a filter, or an image reader. When the input of this filter or reader itself is changed, an error message might be displayed since the current display extent is probably outside the new whole extent. Calling this method will ensure that the display extent is reset properly.
  • int = obj.GetSliceMin () - Return the minimum and maximum slice values (depending on the orientation this can be in X, Y or Z).
  • int = obj.GetSliceMax () - Return the minimum and maximum slice values (depending on the orientation this can be in X, Y or Z).
  • obj.GetSliceRange (int range[2]) - Return the minimum and maximum slice values (depending on the orientation this can be in X, Y or Z).
  • double = obj.GetColorWindow () - Set window and level for mapping pixels to colors.
  • double = obj.GetColorLevel () - Set window and level for mapping pixels to colors.
  • obj.SetColorWindow (double s) - Set window and level for mapping pixels to colors.
  • obj.SetColorLevel (double s) - Set window and level for mapping pixels to colors.
  • obj.SetPosition (int a, int b) - Set/Get the position in screen coordinates of the rendering window.
  • obj.SetPosition (int a[2]) - Set/Get the size of the window in screen coordinates in pixels.
  • obj.SetSize (int a, int b) - Set/Get the size of the window in screen coordinates in pixels.
  • obj.SetSize (int a[2]) - Get the internal render window, renderer, image actor, and image map instances.
  • vtkRenderWindow = obj.GetRenderWindow () - Get the internal render window, renderer, image actor, and image map instances.
  • vtkRenderer = obj.GetRenderer () - Get the internal render window, renderer, image actor, and image map instances.
  • vtkImageActor = obj.GetImageActor () - Get the internal render window, renderer, image actor, and image map instances.
  • vtkImageMapToWindowLevelColors = obj.GetWindowLevel () - Get the internal render window, renderer, image actor, and image map instances.
  • vtkInteractorStyleImage = obj.GetInteractorStyle () - Get the internal render window, renderer, image actor, and image map instances.
  • obj.SetRenderWindow (vtkRenderWindow arg) - Set your own renderwindow and renderer
  • obj.SetRenderer (vtkRenderer arg) - Set your own renderwindow and renderer
  • obj.SetupInteractor (vtkRenderWindowInteractor ) - Attach an interactor for the internal render window.
  • obj.SetOffScreenRendering (int ) - Create a window in memory instead of on the screen. This may not be supported for every type of window and on some windows you may need to invoke this prior to the first render.
  • int = obj.GetOffScreenRendering () - Create a window in memory instead of on the screen. This may not be supported for every type of window and on some windows you may need to invoke this prior to the first render.
  • obj.OffScreenRenderingOn () - Create a window in memory instead of on the screen. This may not be supported for every type of window and on some windows you may need to invoke this prior to the first render.
  • obj.OffScreenRenderingOff () - Create a window in memory instead of on the screen. This may not be supported for every type of window and on some windows you may need to invoke this prior to the first render.
  • int = obj.GetWholeZMin () -