<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">I am trying to read in a raw data file (via MetaImage reader).  It&#39;s skipping the first byte of my file.</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The file, according to xxd -b &lt;file&gt; | less</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<div style="margin-left: 40px; font-family: courier new,monospace;">0000000: 00000000 00001001 00000000 00000110 00000000 00001010  ......<br>0000006: 00000000 00000101 00000000 00000101 00000000 00000110  ......<br>000000c: 00000000 00000000 00000000 00000100 00000000 00000100  ......<br>
0000012: 00000000 00001001 00000000 00000011 00000000 00000100  ......<br></div><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The code:</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><div style="margin-left: 40px; font-family: courier new,monospace;">#include &lt;iostream&gt;<br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>
#include &quot;itkImageFileWriter.h&quot;<br>//#include &quot;itkRawImageIO.h&quot;<br>#include &quot;itkMetaImageIO.h&quot;<br><br>#define print std::cout<br>#define nl    std::endl<br><br>int main( int argc, char** argv )<br>
{<br>  typedef itk::Image&lt; unsigned short, 3 &gt; ImageType;<br><br>  ImageType::Pointer image = ImageType::New();<br><br>  ImageType::IndexType start;<br>  start[0] =   0;  // first index on X<br>  start[1] =   0;  // first index on Y<br>
  start[2] =   0;  // first index on Z<br><br>  ImageType::SizeType  size;<br>  size[0]  = 1388;  // size along X<br>  size[1]  =  560;  // size along Y<br>  size[2]  =   48;  // size along Z<br><br>  ImageType::RegionType region;<br>
  region.SetSize( size );<br>  region.SetIndex( start );<br>  image-&gt;SetRegions( region );<br><br>  image-&gt;Allocate();<br><br>  typedef itk::ImageFileReader&lt; ImageType &gt; ReaderType;<br>  typedef itk::ImageFileWriter&lt; ImageType &gt; WriterType;<br>
  typedef itk::MetaImageIO                  ImageIOType;<br><br>  ImageIOType::Pointer MIIO = ImageIOType::New();<br><br>  ReaderType::Pointer reader = ReaderType::New();<br>  const char * infile = argv[1];<br>  reader-&gt;SetFileName( infile );<br>
  image = reader-&gt;GetOutput();<br>  <br>  print &lt;&lt; &quot;Reading from file (&quot; &lt;&lt; argv[0] &lt;&lt; &quot;)&quot; &lt;&lt; nl;<br>  try{ reader-&gt;Update(); }<br>  catch( itk::ExceptionObject &amp; err )    {<br>
    std::cerr &lt;&lt; &quot;ExceptionObject caught!  Check filename&quot; &lt;&lt; std::endl;<br>    std::cerr &lt;&lt; err &lt;&lt; std::endl;<br>    return EXIT_FAILURE;<br>  }<br><br>  const ImageType::SpacingType&amp; sp = image-&gt;GetSpacing();<br>
  print &lt;&lt; &quot;Spacing = &quot;;<br>  print &lt;&lt; sp[0] &lt;&lt; &quot;, &quot; &lt;&lt; sp[1] &lt;&lt; &quot;, &quot; &lt;&lt; sp[2] &lt;&lt; std::endl;<br><br>  const ImageType::PointType&amp; orgn = image-&gt;GetOrigin();<br>
  std::cout &lt;&lt; &quot;Origin = &quot;;<br>  std::cout &lt;&lt; orgn[0] &lt;&lt; &quot;, &quot; &lt;&lt; orgn[1] &lt;&lt; &quot;, &quot; &lt;&lt; orgn[2] &lt;&lt; std::endl;<br><br>  typedef itk::Point&lt; double, ImageType::ImageDimension &gt; PointType;<br>
<br>  PointType p;<br>  ImageType::IndexType i;<br>  ImageType::PixelType v;<br>  for(  int x = 0;  x &lt; 10;  x += 1  )   {<br>    p[0] = x; p[1] = 0; p[2] = 0;<br>    image-&gt;TransformPhysicalPointToIndex(p,i);<br>    v = image-&gt;GetPixel( i );<br>
    print &lt;&lt; &quot;Value of (&quot; &lt;&lt; p[0] &lt;&lt; &quot;,&quot; &lt;&lt; p[1] &lt;&lt; &quot;,&quot; &lt;&lt; p[2] &lt;&lt; &quot;) is &quot; &lt;&lt; v &lt;&lt; &quot; and has index &quot; &lt;&lt; i &lt;&lt; nl;<br>
  }<br><br>  return 0;<br>}<br></div><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The output:</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><div style="margin-left: 40px; font-family: courier new,monospace;">tukey # make &amp;&amp; ./register img8.mhd<br>Scanning dependencies of target register<br>[100%] Building CXX object CMakeFiles/register.dir/main.cxx.o<br>
Linking CXX executable register<br>[100%] Built target register<br>Reading from file (./register)<br>Spacing = 1.29, 1.29, 5.44<br>Origin = 0, 0, 0<br>Value of (0,0,0) is 2304 and has index [0, 0, 0]<br>Value of (1,0,0) is 1536 and has index [1, 0, 0]<br>
Value of (2,0,0) is 2560 and has index [2, 0, 0]<br>Value of (3,0,0) is 2560 and has index [2, 0, 0]<br>Value of (4,0,0) is 1280 and has index [3, 0, 0]<br>Value of (5,0,0) is 1280 and has index [4, 0, 0]<br>Value of (6,0,0) is 1536 and has index [5, 0, 0]<br>
Value of (7,0,0) is 1536 and has index [5, 0, 0]<br>Value of (8,0,0) is 0 and has index [6, 0, 0]<br><span style="font-family: courier new,monospace;">Value of (9,0,0) is 1024 and has index [7, 0, 0]</span><br style="font-family: courier new,monospace;">
</div><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Looks like the first byte of the file is being skipped.  Is this an error or a feature?</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">KLN</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">---------</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Kevin Neff, Ph.D.</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">Mayo Clinic College of Medicine</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Rochester, MN</span><br style="font-family: courier new,monospace;">
<br><br style="font-family: courier new,monospace;"><br>