[vtkusers] vtkImageReader much faster than vtkImageReader2??

Marco Sambin m.sambin at gmail.com
Thu Jun 12 13:00:54 EDT 2014


Hi all.
I am reading a volume made up of a set of "slices" stored in a single large
raw file, containing just the raw pixels of each slice (unsigned short
values), one slice after the other. I know in advance image size, position,
orientation and spacing information related to each slice.
I used to read my input raw volume through the vtkImageReader2 class, as
documentation of vtkImageReader states:

"vtkImageReader provides methods needed to read a region from a file. It
supports both transforms and masks on the input data, but as a result is
more complicated and slower than its parent class vtkImageReader2."

so I always assumed vtkImageReader2 to be faster than vtkImageReader to
read a simple volume made up of a set of raw slices.
This until today, when I tried replacing my instance of vtkImageReader2
with an instance of vtkImageReader. Guess what? My volume reading code now
executes around 10 times faster!

Is this expected? Can you guess what may be the reason for such a
significant difference in performance between vtkImageReader2 and
vtkImageReader, the latter being much faster in my scenario (despite what
the documentation states)?

For completeness, I am using VTK 6.1 64-bit from Java 7 64-bit, under
Windows 7 Professional 64-bit. Here is a code fragment showing how I
configure my reader:

[...]
imageReaderVTK =  new vtkImageReader(); // much slower if I use
"vtkImageReader2" here
imageReaderVTK.FileLowerLeftOn();
imageReaderVTK.SetFileDimensionality(3);
imageReaderVTK.SetFileName(curRawVolFile.getAbsolutePath());
imageReaderVTK.SetDataExtent(0, sliceCols - 1,
                      0, sliceRows - 1,
                      0, numOfUsedImages - 1);
imageReaderVTK.SetDataSpacing(xSpacing, ySpacing, zSpacing);
imageReaderVTK.SetDataOrigin(0.0, 0.0, 0.0);
imageReaderVTK.SetDataScalarTypeToUnsignedShort();
imageReaderVTK.SetDataByteOrderToBigEndian();
imageReaderVTK.UpdateWholeExtent();
[...]

My typical input raw volume is made up of around 500 slices, each one
512x512 pixels large.

Thanks in advance for your feedback.
Best regards,

Marco Sambin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140612/4ab3c2de/attachment.html>


More information about the vtkusers mailing list