<div dir="ltr">Hi all.<div>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.</div>
<div>I used to read my input raw volume through the vtkImageReader2 class, as documentation of vtkImageReader states:</div><div><br></div><div>"<span style="color:rgb(38,38,38);font-family:arial,sans-serif;font-size:13px;line-height:16px">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."</span></div>
<div><span style="color:rgb(38,38,38);font-family:arial,sans-serif;font-size:13px;line-height:16px"><br></span></div><div><span style="color:rgb(38,38,38);font-family:arial,sans-serif;font-size:13px;line-height:16px">so I always assumed vtkImageReader2 to be faster than vtkImageReader to read a simple volume made up of a set of raw slices.</span></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">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!</span></font></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">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)?</span></font></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">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:</span></font></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">[...]</span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><div style>
imageReaderVTK =  new vtkImageReader(); // much slower if I use "vtkImageReader2" here</div><div style>imageReaderVTK.FileLowerLeftOn();</div><div style>imageReaderVTK.SetFileDimensionality(3);</div><div style>imageReaderVTK.SetFileName(curRawVolFile.getAbsolutePath());</div>
<div style>imageReaderVTK.SetDataExtent(0, sliceCols - 1,</div><div style>                      0, sliceRows - 1,</div><div style>                      0, numOfUsedImages - 1);</div><div style>imageReaderVTK.SetDataSpacing(xSpacing, ySpacing, zSpacing);</div>
<div style>imageReaderVTK.SetDataOrigin(0.0, 0.0, 0.0);</div><div style>imageReaderVTK.SetDataScalarTypeToUnsignedShort();</div><div style>imageReaderVTK.SetDataByteOrderToBigEndian();</div><div style>imageReaderVTK.UpdateWholeExtent();</div>
</span></font></div><div><span style="color:rgb(38,38,38);font-family:arial,sans-serif;line-height:16px">[...]</span></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">My typical input raw volume is made up of around 500 slices, each one 512x512 pixels large.</span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br>
</span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">Thanks in advance for your feedback.</span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">Best regards,</span></font></div>
<div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px"><br></span></font></div><div><font color="#262626" face="arial, sans-serif"><span style="line-height:16px">Marco Sambin</span></font></div>
<div><br></div></div>