[vtkusers] how to read a stack of images at a time...using TCL script

John Hunter jdhunter at ace.bsd.uchicago.edu
Sat Oct 11 08:51:45 EDT 2003


>>>>> "GV," == V, Sowjanya (CORP, GEITC, Intern) <sowjanya.v at ge.com> writes:

    GV,> Hi, I tried to convert on single image to polydata ,i got it,
    GV,> but i need to do the same for a stack of images.  If anybody
    GV,> knows about this plz let me know.

You can read the data in with an image reader appropriate for your
format (what are the images?) such as 

  reader = vtk.vtkBMPReader()
  reader.SetDataExtent(0,511,0,511,100,147)
  reader.SetFilePrefix('somedir/image)
  reader.SetFilePattern( '%s/%03d.bmp')

This will read files (512x512 bitmaps)

  somedir/image100.bmp
  somedir/image101.bmp 
  ...
  somedir/image147.bmp 

You can get the vtkImageData output with 

  imageData = reader.GetOutput().  

which can be used with vtkImageDataGeometry filter

  filter = vtk.vtkImageDataGeometryFilter()
  filter.SetInput(imageData)
  polyData = filter.GetOutput()

Warning, the above is untested -- it's just put together from my
reading of the class API at
http://www.vtk.org/doc/nightly/html/classes.html 

See Medical/Cxx/Medical3.cxx for examples of using filters with image
data from a series of images.

Good luck,
John Hunter



More information about the vtkusers mailing list