[vtkusers] vtkDataArray: Memory allocation problem

Malsoaz James jmalsoaz at yahoo.fr
Wed Jan 27 03:21:23 EST 2010


Thanks for the answer. I guess I need to add some explanation to my application.



I'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.

Here is the code for this part:



scalars=vtkIntArray::New();

scalars->SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);



std::vector <ImageType::Pointer>::iterator iterator;

iterator = SlicesList.begin();



for (unsigned int lz=0;lz<numberOfSlice;lz++)

    {

        itk::ImageRegionConstIterator<ImageType>  inputIt(*iterator, (*iterator)->GetLargestPossibleRegion());

        inputIt.GoToBegin();

        int currentvalue;

        while( !inputIt.IsAtEnd() )

        {

            lurrentvalue = inputIt.Get();

            m_scalars->SetValue(offset,currentvalue);

            offset++;

            ++inputIt;

        iterator++;

    }




As I said, this is working and I have been able to allocate X*Y*Z elements in my vtkIntArray.



Then, I'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.

In order to display these boundaries on the vtkVolume, I'm building a
new 3D volume with only the boundaries. Further to this, I'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'm using:



vtkIntArray* scalars = vtkIntArray::New();

scalars->SetNumberOfValues(nbPixelX*nbPixelY*nbPixelZ);

for (points in my boundaries)

{


scalars->SetValue(offset,1);


}


Note that the error appears at the first "SetValue". I have been trying
to fill the new volume with 0 using "InsertTuple1(offset, 0)". Thus,
I'm able to see where the allocation is crashing. It seems to be around
the 33 555 448th elements. I can't explain why.



I hope this has clarify my problem.

Best

James

--- En date de : Mar 26.1.10, Bill Lorensen <bill.lorensen at gmail.com> a écrit :

De: Bill Lorensen <bill.lorensen at gmail.com>
Objet: Re: [vtkusers] vtkDataArray: Memory allocation problem
À: "Malsoaz James" <jmalsoaz at yahoo.fr>
Cc: vtkusers at vtk.org
Date: Mardi 26 Janvier 2010, 16h10

Are there other filters involved in the processing? What does your vtk pipeline look like?

On Tue, Jan 26, 2010 at 10:59 AM, Malsoaz James <jmalsoaz at yahoo.fr> wrote:


Hello,

First of all, I would like to expose the context of my problem. I'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(). 



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'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).

For information, the images have a size of 512*512.

Do you know what is the
 origin of the problem? How can I solve this ?


Best
James






      
_______________________________________________

Powered by www.kitware.com



Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html



Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ



Follow this link to subscribe/unsubscribe:

http://www.vtk.org/mailman/listinfo/vtkusers







      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100127/666b2233/attachment.htm>


More information about the vtkusers mailing list