[vtkusers] Streamed input/output

Kevin H. Hobbs hobbsk at ohiou.edu
Mon Sep 29 14:01:42 EDT 2008


On Mon, 2008-09-29 at 14:13 +0200, Milos Sramek wrote:
> Hi,
> 
> Does streaming in VTK work for input and output?

Yes, but not all combinations of reader, algorithm, and writer stream.

> 
> streamer = vtkMemoryLimitImageDataStreamer()
> streamer.SetInput(mag2.GetOutput())
> streamer.SetMemoryLimit(1000)
> 
> mhdwriter = vtkMetaImageWriter()
> mhdwriter.SetFileName("mhdWriter.mhd")
> mhdwriter.SetInput(streamer.GetOutput())
> mhdwriter.Write()


>  Streaming obviously works well, but not for the vtkMetaImageWriter().
> 

I've had the best results with streaming using the XML image readers and
writers which read and write blocks of the image not slices. 

I suggest that you ditch the vtkMemoryLimitImageDataStreamer, connect
the vtkImageShrink3D directly to the writer and tell the writer to write
slice by slice ( I don't know if the last part works.)

> If vtkImageGaussianSource() is replaced by vtkImageReader2, the program 
> crashes for big data.
> Do I do something wrong?

No, you just aren't really telling it to stream. In what you have the
streamer and the writer will want a copy of the image. If the image
itself is bigger than the memory or the address space then you're stuck.

Why don't you try this:

reader = vtkImageGaussianSource()
reader.SetWholeExtent(0,511,0,511,0,511) #1GB volume, 8bytes/voxel

mag1 = vtkImageMagnify()
mag1.SetInputConnection(reader.GetOutputPort())
mag1.SetMagnificationFactors(2, 2, 2) # 8GB here

mag2 = vtkImageShrink3D()
mag2.SetInputConnection(mag1.GetOutputPort())
mag2.SetShrinkFactors(4,4,4) # 128MB here

mhdwriter = vtkMetaImageWriter()
mhdwriter.SetFileName("mhdWriter.mhd")
mhdwriter.SetFileDimensionality( 2 )
mhdwriter.SetInputConnection(mag2.GetOutputPort())

mhdwriter.Write()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080929/80a49ba9/attachment.pgp>


More information about the vtkusers mailing list