[vtkusers] Streamed input/output

Milos Sramek sramek.milos at gmail.com
Wed Oct 1 07:51:56 EDT 2008


Dear Kevin,

thank you for your answer. I did not know about the XML format - writing 
to it now,  the system is streaming correctly even without using the 
vtkMemoryLimitImageDataStreamer module.

Thanks again!
Milos

Kevin H. Hobbs wrote:
> 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()
>   


-- 
email & jabber: sramek.milos at gmail.com




More information about the vtkusers mailing list