[vtkusers] Combining multiple ImageData objects into a single ImageData object

Matthew Betney mrbetney at gmail.com
Fri Feb 22 13:04:11 EST 2013


I've got a set of vtkImageData objects that come from different processors
of a parallel simulation, where each object corresponds to a different
spatial section of the total dataset. I'm not able to change how the files
are generated, and thus don't think I can use a pvti file. I need to
combine these into one imagedata object, but I'm running into problems. The
data in the ImageData objects is cell wise constant

I've tried using vtkImageAppend, but I keep running into memory errors:
imgs = {}
for i in range(0, self._nprocs):
       img = read_vti_file(vti_files[i])
       origin = img.GetOrigin()
       imgs[origin] = img
keys = imgs.keys()
keys.sort(key=itemgetter(1, 0))  # sort by y first, then x

img_append = vtk.vtkImageAppend()
for k, g in groupby(keys, lambda x: x[1]):
    row_img = vtk.vtkImageAppend()
    for origin in g:

As an alternative method, I've tried using vtk.vtkAppendFilter() to join
the imagedata objects. This works, but the output is an UnstructuredGrid,
which I haven't been able to convert to an ImageData object. I've tried
using vtkProbeFilter to do this, but the vtkImageData object returned is
interpolated from the UnstructuredGrid, whereas I need the data to be cell
wise constant.

Any help combining the imagedata objects, or converting an UnstructuredGrid
to an ImageData object would be greatly appreciated.

Many thanks,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130222/f13c49ad/attachment.htm>

More information about the vtkusers mailing list