[vtkusers] how to display a serie of XA multiframe images

José M. Rodriguez Bacallao jmrbcu at gmail.com
Fri Jul 6 10:01:57 EDT 2012


and if I am not using any lookup table, for example, this is my test
source code, how do I change from one multiframe image to another as I
cannot use SetVectorComponent(n)?:

import os, sys
import vtk, vtkgdcm, gdcm


if __name__ == '__main__':
    # 2 XA multiframe images
    path = '/home/jmrbcu/temp/images/XA'
    print 'Reading files from %s' % path
    files = os.listdir(path)
    files = [os.path.join(path, x) for x in files]

    appender = vtk.vtkImageAppendComponents()
    for name in files:
        reader = vtkgdcm.vtkGDCMImageReader()
        reader.SetFileName(name)
        appender.SetInput(reader.GetOutput())
        appender.Update()

    ren1 = vtk.vtkRenderer()
    renWin = vtk.vtkRenderWindow()
    renWin.AddRenderer(ren1)

    im = vtk.vtkImageResliceMapper()
    im.SetInput(appender.GetOutput())
    im.SliceFacesCameraOn()
    im.SliceAtFocalPointOn()
    im.BorderOff()

    ip = vtk.vtkImageProperty()
    ip.SetColorWindow(255)
    ip.SetColorLevel(128)
    ip.SetAmbient(0.0)
    ip.SetDiffuse(1.0)
    ip.SetOpacity(1.0)
    ip.SetInterpolationTypeToLinear()

    ia = vtk.vtkImageSlice()
    ia.SetMapper(im)
    ia.SetProperty(ip)

    print ip.GetLookupTable()

    ren1.AddViewProp(ia)
    ren1.SetBackground(0, 0, 0)
    renWin.SetSize(400, 400)

    iren = vtk.vtkRenderWindowInteractor()
    style = vtk.vtkInteractorStyleImage()
    style.SetInteractionModeToImageSlicing()
    style.SetCurrentRenderer(ren1)
    iren.SetInteractorStyle(style)
    renWin.SetInteractor(iren)

    cam = ren1.GetActiveCamera()
    cam.ParallelProjectionOn()
    ren1.ResetCameraClippingRange()
    ren1.ResetCamera()
    renWin.Render();
    iren.Start()

by the way, Mathieu, this XA multiframe images when displaying it with
gdcmviewer a lot of frames in the middle show black, I could send it
to you to see if you got this behavior.

On Thu, Jul 5, 2012 at 12:35 PM, David Gobbi <david.gobbi at gmail.com> wrote:
> A trick that I've used for multi-frame images in VTK is to read them
> separately, and then combine them into a single image with
> vtkImageAppendComponents.  The result is a multi-component image
> where each component represents a different frame.  When these
> multi-component images are displayed, you can control which component
> is displayed by calling SetVectorComponent(i) on the lookup table that
> you are using for the images.
>
> In other words, the multi-frame image is multiplexed into a multi-
> component image.  Dealing with multi-component images in VTK is
> fairly straightforward.
>
>  - David
>
>
> On Thu, Jul 5, 2012 at 10:18 AM, José M. Rodriguez Bacallao
> <jmrbcu at gmail.com> wrote:
>> hi folks, this question may seen obvious but, how to correctly display
>> a serie of XA multiframe images (17 multiframe images) with vtk, The
>> images are read with gdcm vtk reader (vtkGDCMImageReader) one by one
>> because this reader does not  support the reading of multiframe image
>> series.



More information about the vtkusers mailing list