<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Zhangliu,<div><br></div><div>The c is for the component number, and there is an extraneous '+' before the ySize. The component number is only needed for vector images.</div><div><br></div><div>I don't seem to be able to find an example with utilizing the IntPtr. I have been told it's straightforward. I'll try to dig into some C# stuff tomorrow to make an example.</div><div><br></div><div>Brad</div><div><br><div><div>On Jan 12, 2014, at 3:24 PM, Zhongliu Xie <<a href="mailto:zhongliu.xie10@imperial.ac.uk">zhongliu.xie10@imperial.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Dear Brad,<br>
      Thanks for your reply. Yet the method image.GetBufferAsFloat()
      returns an IntPtr, how do I convert it to float[] then? Also, in
      the SimpleITK docs it says:<br>
      <div class="fragment" style="font-weight: normal; font-style: normal; font-variant: normal; font-size: 14.399999618530273px; line-height: 19px; font-family: Roboto, sans-serif; padding: 4px; margin: 4px; background-color: rgb(251, 252, 253); border: 1px solid rgb(196, 207, 229); letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">
        <div class="line" style="font-weight: 400; font-style: normal;
          font-variant: normal; font-size: 13px; line-height: 1;
          font-family: monospace, fixed; min-height: 13px; white-space:
          pre-wrap; word-wrap: break-word; text-indent: -53px;
          padding-left: 53px; padding-bottom: 0px; margin: 0px;
          -webkit-transition: background-color 0.5s, box-shadow;">uint8_t
          *buffer = img->GetBufferAsUInt8();</div>
        <div class="line" style="font-weight: 400; font-style: normal;
          font-variant: normal; font-size: 13px; line-height: 1;
          font-family: monospace, fixed; min-height: 13px; white-space:
          pre-wrap; word-wrap: break-word; text-indent: -53px;
          padding-left: 53px; padding-bottom: 0px; margin: 0px;
          -webkit-transition: background-color 0.5s, box-shadow;">buffer[c
          + numComponents*(x+ xSize* (y*+ySize*z))]</div>
      </div>
      what is c in this case?<br>
      <br>
      Regards,<br>
      Zhongliu<br class="Apple-interchange-newline">
      <br>
      <br>
      On 12/01/2014 20:07, Bradley Lowekamp wrote:<br>
    </div>
    <blockquote cite="mid:D9ABA98D-212B-4F28-8B5A-D0BB053B20B3@mail.nih.gov" type="cite">
      <pre wrap="">Hello,

Available only in C++ and C#, are a set of methods which being as "GetBufferAs":

itk::simple::Image::GetBufferAsInt8;
itk::simple::Image::GetBufferAsUInt8;
itk::simple::Image::GetBufferAsInt16;
itk::simple::Image::GetBufferAsUInt16;
itk::simple::Image::GetBufferAsInt32;
itk::simple::Image::GetBufferAsUInt32;
itk::simple::Image::GetBufferAsInt64;
itk::simple::Image::GetBufferAsUInt64;
itk::simple::Image::GetBufferAsFloat;
itk::simple::Image::GetBufferAsDouble;

These return a pointer or array to the image buffer that you are looking for. The correctly typed method mush be call, or else an exception will be thrown. The array returned has not line padding, and a SimpleITK image always begins with an index of [0,0,0].

This is a 1-D array but can be access as a 3-D. Given an image of size [xS,yS,zS], you can access the image at index [x,y,z] as you wish by image[x+y*xS+z*xS*yS], so x is the fastest axis and z is the slowest.

Brad


On Jan 12, 2014, at 1:35 PM, Zhongliu Xie <a class="moz-txt-link-rfc2396E" href="mailto:zhongliu.xie10@imperial.ac.uk"><zhongliu.xie10@imperial.ac.uk></a> wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">Dear fellow ITK users,

Recently I have been using Simple ITK under C# environment. I wonder whether there is a way to quickly convert an image into an array of intensities (leaving out the meta info)? In particular, is it possible to directly convert to a multidimensional array such as intensity[x,y,z] (or intensity[x][y][z] in C++) indicating the intensity of voxel at <x,y,z>?

BTW, I also noticed there is something called Buffer which seems related. Could someone explain what  buffer is more explicitly so that I can make sure I understand it correctly?

Thanks in advance,
Zhongliu
_____________________________________
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>

Kitware offers ITK Training Courses, for more information visit:
<a class="moz-txt-link-freetext" href="http://www.kitware.com/products/protraining.php">http://www.kitware.com/products/protraining.php</a>

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

Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.itk.org/mailman/listinfo/insight-users">http://www.itk.org/mailman/listinfo/insight-users</a>
</pre>
      </blockquote>
      <pre wrap=""></pre>
    </blockquote>
    <br>
  </div>

</blockquote></div><br></div></body></html>