[vtkusers] Faster slice display

David Gobbi dgobbi at irus.rri.ca
Mon Jun 18 16:29:21 EDT 2001


On Mon, 18 Jun 2001, TJ Wilkinson wrote:

> David-
>
> Thank you for your help.  After implementing your suggestions, I have the
> following observations and questions.
>
> Turning double buffering on didn't seem to make much difference.

This might depend on the machine.  On several platforms, rendering to
the front buffer is completely unaccelerated.  On others, it is
accelerated.

> I was also not able to successfully run reader->Update().  When you say
> "right after you read the image", I am actually not certain about where
> that happens.

What I meant was after you had set up the ImageReader, but before anything
else.  Calling reader->Update() will force the reader to read all the
slices into memory.  But considering the volume size you mention below,
you don't want to do this, you'll just run your computer out of memory.

> The image sets I am loading are at largest 1024 square with 360 slices.
> Simply put, the maximum file size is about 1.3 GB.  The viewer setup I
> have now seems to read the last 60 or so slices quickly, while the first
> 300 are slow.  To me, that says that the last 60 slices may be cached in
> some way.

A hah.  You should have mentioned this earlier.  Caching the whole volume
in memory is not an option then.  Disk access is going to be the
bottleneck, then.  Or even worse, you might be running yourself out of
physical memory.

> I know you said that the input volume size probably wouldn't matter too
> much,

Yes, but I had assumed the whole volume could be loaded at once...

The first thing to try is no caching, always read from disk (this
might be faster just because it will keep your computer from running
out of memory):
  1) if you have a reader.Update() anywhere, remove it
  2) add the call '.ReleaseDataFlagOn()' in the setup of all filters

The second thing to try, if the above doesn't speed things up, is
to use a low-res volume as you said.  You can reduce the resolution as
follows:

shrink = vtkImageReslice()
shrink.SetInput(reader.GetOutput())
shrink.SetOutputSpacing(x,y,z)  # --- set to 4X the input spacing
shrink.UpdateWholeExtent()      # --- update & cache low-res volume

data = shrink.GetOutput()
data.SetSource(None)  # use NULL if programming in C++

del shrink     # delete the shrinker  (->Delete from C++)
del reader     # delete the reader

Now 'data' has a cache of the low-res volume.  It will still take a
lot of time to read & shrink the data, but afterwards you will be able to
slice through it very fast.  Also, in future posts when you refer to
'slow' or 'fast' please give an estimate of the frames per second.
I usually consider anything less than 5 frames/s to be 'slow.'

 - David





More information about the vtkusers mailing list