<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Mengda,<br>
      <br>
      yes, doing the computation yourself is faster. An example was
      given here:
<a class="moz-txt-link-freetext" href="http://vtk.1045678.n5.nabble.com/Fast-element-access-of-vtkImageData-td4640137.html#a4640179">http://vtk.1045678.n5.nabble.com/Fast-element-access-of-vtkImageData-td4640137.html#a4640179</a><br>
      <br>
      As also was pointed out in this thread another option are image
      iterators. However, I don't know if they are as fast as direct
      access.<br>
      <br>
      Regards,<br>
      Dominique<br>
      <br>
      Am 20.11.2013 05:30, schrieb Mengda Wu:<br>
    </div>
    <blockquote
cite="mid:CALmcJSDj-S7UN3AOZ3Y-nmHet46DXLeD5HOY3dwXVSS4v8+g1A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>Hi all,<br>
                <br>
              </div>
              &nbsp;&nbsp; I am trying to use vtkImageData::GetScalarPointer
              inside the loop through all the voxels in a huge 3D image
              (512x512x300). But it seems this function is pretty slow.
              A code sample is like this:<br>
              <br>
              &nbsp;&nbsp; int* dims = aImage-&gt;GetDimensions();<br>
              &nbsp;&nbsp; int dim[3];<br>
              &nbsp;&nbsp; for(dim[2] = 0; dim[2] &lt; dims[2]; dim[2]++)<br>
              &nbsp;&nbsp;&nbsp; {<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(dim[1] = 0; dim[1] &lt; dims[1]; dim[1]++)<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for(dim[0] = 0; dim[0] &lt; dims[0]; dim[0]++)<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; {<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; double* curr =
              static_cast&lt;double*&gt;(aImage-&gt;GetScalarPointer(dim));<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *currhist = 1.0;<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
              &nbsp;&nbsp;&nbsp; }<br>
              <br>
            </div>
            &nbsp;&nbsp; I mean should I just get the pointer of the first vosel
            and compute the poitner addresses for the rest of voxels
            myself? Should it be faster? Does vtkImageData store all
            voxels continuously? What about if I have multiple
            components per voxel?<br>
            <br>
          </div>
          Thanks,<br>
        </div>
        Mengda<br>
        <div>
          <div>
            <div>&nbsp; <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Powered by <a class="moz-txt-link-abbreviated" href="http://www.kitware.com">www.kitware.com</a>

Visit other Kitware open-source projects at <a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>

Please keep messages on-topic and check the VTK FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>