<div dir="ltr">Hi David,<br><br>Now I realized the problem/limitation of multi-dimensional C array!<br><br>Since I could not find out any example in Google on how to create C arrays with strides, I ended up in using boost multi_array.<br>
It&#39;s quite good, but the problem is when the array dimensions increase to about 500x500x500, I get a strange run time error. I googled about this and found that the errors occurs when the system can&#39;t allocate CONTIGUOUS MEMORY.<br>
<br>Now I realize the reason behind your suggestion to use arrays with strides. I am resampling the vtkImageData to 1mm spacing from 2.5mm in all 3 dimensions. So there could be a factor of 8 increase in memory requirement. I tried to set the scalar data type to float even. <br>
<br>I desperately need to use 1mm dimensions for my research.<br><br>I have only 2GB RAM on win XP. I will try on the other computer with higher RAM.<br><br>Do you have any example or references for creating arrays with strides.<br>
<br>You were correct,C array are useless for image processing!<br><br>Thank you<br><br>Jothy<br><br><div class="gmail_quote">On Fri, Aug 19, 2011 at 5:29 PM, David Gobbi <span dir="ltr">&lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Jothy,<br>
<br>
I&#39;m not telling you to not use a C array.  What I&#39;m telling you is<br>
that you should use a 1D C array with strides for each dimension.<br>
Do not use a 3D C array.  Read up on strides and learn how to use<br>
them.  You&#39;ll thank me later.<br>
<font color="#888888"><br>
 - David<br>
</font><div><div></div><div class="h5"><br>
<br>
On Fri, Aug 19, 2011 at 10:23 AM, Jothy &lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt; wrote:<br>
&gt; Thanks for your reply.<br>
&gt;<br>
&gt; I don&#39;t need to do any image processing with that C array. I need to get the<br>
&gt; scalar values at [x,y,z] for a huge list of points from the vtkImageData<br>
&gt; (they are randomly located). First I tried with<br>
&gt; GetScalarComponentAsDouble(x,y,z,0).<br>
&gt;<br>
&gt; But it&#39;s too slow (for my purpose, 20-30 secs). After some Google search, I<br>
&gt; came to know that acessing array with [] will be much faster that<br>
&gt; GetscalarComponent.<br>
&gt;<br>
&gt; I even looked at vtkImageIterator, it only has methods span, begin,end. Most<br>
&gt; importantly I need to copy those scalar values for later uses, so mere<br>
&gt; scalar pointers won&#39;t help. That&#39;s why I am trying to do it with a c array.<br>
&gt;<br>
&gt; Jothy<br>
&gt;<br>
&gt; On Fri, Aug 19, 2011 at 5:15 PM, David Gobbi &lt;<a href="mailto:david.gobbi@gmail.com">david.gobbi@gmail.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi Jothy,<br>
&gt;&gt;<br>
&gt;&gt; You probably don&#39;t want to create a 3D C array.  In C, all dimensions<br>
&gt;&gt; of a C array except for the first dimension must be constant.  So if<br>
&gt;&gt; you have variables N and M and you try doing this:<br>
&gt;&gt;<br>
&gt;&gt; short myarray[N][M];<br>
&gt;&gt;<br>
&gt;&gt; then you will get a compile error.  Multidimensional C arrays are<br>
&gt;&gt; pretty much useless for image processing, people generally use a<br>
&gt;&gt; 1D array and strides/increments.  Do a search for &quot;array strides&quot; on<br>
&gt;&gt; google.<br>
&gt;&gt;<br>
&gt;&gt;  - David<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Aug 19, 2011 at 9:54 AM, Jothy &lt;<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>&gt; wrote:<br>
&gt;&gt; &gt; Hi all,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I am trying to create a 3D C array form vtkImageData. I tried<br>
&gt;&gt; &gt; vtkImageExport, but I seems like only exporting it as a 1D array. Is<br>
&gt;&gt; &gt; there<br>
&gt;&gt; &gt; any other filter or how to convert it to a 3D array? I am new to c++ and<br>
&gt;&gt; &gt; I<br>
&gt;&gt; &gt; don&#39;t find any matrix manipulation function as in MATLAb or Python in c<br>
&gt;&gt; &gt; std<br>
&gt;&gt; &gt; lib.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Thank you<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Jothy<br>
</div></div></blockquote></div><br></div>