[vtkusers] image viewer in small window

John Hunter jdhunter at ace.bsd.uchicago.edu
Wed Apr 16 18:44:56 EDT 2003


I want to display some 3D BMP image data with a vtkImageViewer in a
small preview window.  The data are 512x512 and the preview window is
256x256.  If I don't transform the data, only a quadrant of the image
is shown in the preview window.  So I am transforming the image data
with vtkTransform and vtkImageReslice to get it to fit in the smaller
window.

    outDim = 256
    inDim = 512
    scale = inDim/outDim
    transform = vtk.vtkTransform()
    transform.Scale(scale, scale, scale)
    reslice = vtk.vtkImageReslice()
    reslice.SetInput(reader.GetOutput())
    reslice.SetResliceTransform(transform)

    viewer = vtk.vtkImageViewer()
    viewer.SetInput(reslice.GetOutput())
        ...some other viewer commands ...

    preview = GtkGLExtVTKRenderWindow()
    preview.set_size_request(outDim, outDim)
    preview.show()

This works, but it seems like a lot of work for an easy task.  Is this
the right way to do it?

Thanks,
John Hunter



More information about the vtkusers mailing list