<br>I&#39;m curious, why don&#39;t you use the dicomseriesreader? Shown below here is an example to create a metaImage volume,<br>but writing a VTK volume should be nearly identical:<br><br>int main(int argc, char *argv[])<br>

{<br>  if(argc != 3)<br>    {<br>    vtkstd::cout &lt;&lt; &quot;Required arguments: Folder containing .dcm files and also name of OutputFile&quot; &lt;&lt; vtkstd::endl;<br>    }<br>  vtkstd::string folder = argv[1];<br>

  vtkstd::string outputFile = argv[2];<br> <br>  // Read all the DICOM files in the specified directory.<br>  vtkSmartPointer&lt;vtkDICOMImageReader&gt; reader = vtkSmartPointer&lt;vtkDICOMImageReader&gt;::New();<br>  reader-&gt;SetDirectoryName(folder.c_str());<br>

  reader-&gt;Update();<br> <br>  vtkImageData* imagedata = reader-&gt;GetOutput();<br>  vtkSmartPointer&lt;vtkMetaImageWriter&gt; metaImageWriter = vtkSmartPointer&lt;vtkMetaImageWriter&gt;::New();<br>  metaImageWriter-&gt;SetInput(imagedata);<br>

  metaImageWriter-&gt;SetFileName(outputFile.c_str());<br>  metaImageWriter-&gt;Update();<br> <br>  return 0;<br>}<h2 style="color: rgb(159, 197, 232);"><a name="TOC-CMakeLists.txt"></a> <span></span></h2>Michael<br><br>
<div class="gmail_quote">
On Wed, Jan 27, 2010 at 8:21 AM, Malsoaz James <span dir="ltr">&lt;<a href="mailto:jmalsoaz@yahoo.fr">jmalsoaz@yahoo.fr</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">

Thanks for the answer. I guess I need to add some explanation to my application.<br>
<br>
I&#39;m reading a Dicom series using ITK to build a 3D vtk volume. This
part is working well whatever the number of slices. I have no problem
for the allocation with vtkIntArray.<br>
Here is the code for this part:<br>
<br>
<div style="margin-left: 40px;">scalars=vtkIntArray::New();<br>
scalars-&gt;SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);<br>
<br>
std::vector &lt;ImageType::Pointer&gt;::iterator iterator;<br>
iterator = SlicesList.begin();<br>
<br>
for (unsigned int lz=0;lz&lt;numberOfSlice;lz++)<br>
    {<br>
        itk::ImageRegionConstIterator&lt;ImageType&gt;  inputIt(*iterator, (*iterator)-&gt;GetLargestPossibleRegion());<br>
        inputIt.GoToBegin();<br>
        int currentvalue;<br>
        while( !inputIt.IsAtEnd() )<br>
        {<br>
            lurrentvalue = inputIt.Get();<br>
            m_scalars-&gt;SetValue(offset,currentvalue);<br>
            offset++;<br>
            ++inputIt;<br>
        iterator++;<br>
    }<br>
<br>
</div>
As I said, this is working and I have been able to allocate X*Y*Z elements in my vtkIntArray.<br>
<br>
Then, I&#39;m working with ITK to do some process with ITK (threshold,
opening, closing, labeling, ...). At the end, I have the boundaries of
some objects in my slices.<br>
In order to display these boundaries on the vtkVolume, I&#39;m building a
new 3D volume with only the boundaries. Further to this, I&#39;m displaying
the boundaries on the raw volume using Texture. The error of allocation
appears here and only when the number of slices in my volume is
important (more than 300 slices). Here is the code I&#39;m using:<br>
<br>
<div style="margin-left: 40px;">vtkIntArray* scalars = vtkIntArray::New();<br>
scalars-&gt;SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);<br>
for (points in my boundaries)<br>
{<br>
</div>
<div style="margin-left: 80px;">scalars-&gt;SetValue(offset,1);<br>
</div>
<div style="margin-left: 40px;">}<br>
</div>
Note that the error appears at the first &quot;SetValue&quot;. I have been trying
to fill the new volume with 0 using &quot;InsertTuple1(offset, 0)&quot;. Thus,
I&#39;m able to see where the allocation is crashing. It seems to be around
the 33 555 448th elements. I can&#39;t explain why.<br>
<br>
I hope this has clarify my problem.<br>
Best<br>
James<br><br>--- En date de : <b>Mar 26.1.10, Bill Lorensen <i>&lt;<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;</i></b> a écrit :<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;">

<br>De: Bill Lorensen &lt;<a href="mailto:bill.lorensen@gmail.com" target="_blank">bill.lorensen@gmail.com</a>&gt;<br>Objet: Re: [vtkusers] vtkDataArray: Memory allocation problem<br>À: &quot;Malsoaz James&quot; &lt;<a href="mailto:jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>&gt;<br>

Cc: <a href="mailto:vtkusers@vtk.org" target="_blank">vtkusers@vtk.org</a><br>Date: Mardi 26 Janvier 2010, 16h10<div><div></div><div class="h5"><br><br><div>Are there other filters involved in the processing? What does your vtk pipeline look like?<br>

<br><div class="gmail_quote">On Tue, Jan 26, 2010 at 10:59 AM, Malsoaz James <span dir="ltr">&lt;<a rel="nofollow" href="http://mc/compose?to=jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">


Hello,<br><br>First of all, I would like to expose the context of my problem. I&#39;m working on an application which is in charge of loading/building a 3D volume from Dicom files. The building of the 3D volume is working perfectly using a vtkIntArray and setScalars(). <br>


<br><br>Unfortunately, later in the software, I need to rebuild a new 3D volume using one more time vtkIntArray with the same size but I got an error like: vtkIntArray: Unable to allocate X elements of size 4. Although I have enough memory (I have 3Go of RAM), I&#39;m doing exactly the same thing as the first build and the charge on Windows for the application is always under 1Go. My application is working with small volume (ie 150 slices) and I got this allocation error with big volume (ie more than 300 slices).<br>


For information, the images have a size of 512*512.<br><br>Do you know what is the
 origin of the problem? How can I solve this ?<br><br><br>Best<br>James<br></td></tr></tbody></table><br>




      <br>_______________________________________________<br>
Powered by <a rel="nofollow" href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a rel="nofollow" href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a rel="nofollow" href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a rel="nofollow" href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>
</div></div></div></blockquote></td></tr></tbody></table><br>




      <br>_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
<br></blockquote></div><br>