[vtkusers] reading a stack of bmp files
John Hunter
jdhunter at ace.bsd.uchicago.edu
Mon Apr 5 09:13:11 EDT 2004
>>>>> "megha" == megha agarwal <megha_agar at yahoo.co.in> writes:
megha> Dear frens' I have a series of bmp files say foo1.bmp,
megha> foo2.bmp......etc. I want to read in these files and stack
megha> them to generate a 3D image. Plz suggest.
# For 512 x 512 images foo1 to foo100
reader = vtk.vtkBMPReader()
reader.SetDataExtent(0, 511, 0, 511, 1, 100)
reader.SetFilePrefix('/path/to/foo')
# %s is the prefix above. %d is the format string for the numbers;
# Eg, use%03d for files like foo001.bmp, etc
reader.SetFilePattern('%s/%d.bmp')
reader.SetDataSpacing(sx, sy, sz) # convert to data coords if you want
imageData = reader.GetOutput()
You can pass the image data to whatever image handler you want, eg
vtkImagePlaneWidget...
JDH
More information about the vtkusers
mailing list