[vtkusers] troubles with memory

Mathieu Malaterre mathieu.malaterre at kitware.com
Fri Apr 2 17:39:11 EST 2004


Ivan,

	There is an entry in the VTK FAQ:

[How to handle large data sets in VTK]
http://public.kitware.com/cgi-bin/vtkfaq?req=show&file=faq03.007.htp

You should really delete image as soon as you don't need them anymore. 
Remeber that VTK doesn't not modify input, there is no inplace filter. 
So each time you are using a filter you basically double memory usage.

HTH
Mathieu

Ivan Dmitriev wrote:
> Hi people !
> 
>    Currently I'm using VTK 4.2. There is a program which needs some 
> filters from VTK library (vtkImageGaussianSmooth, vtkContourFilter and 
> so on). For GUI I'm using QT 2.3 Non comercial. Pipeline of the program is:
> 
> - Load DICOM files in memory (from 180 slices up to 700, depence on scan)
> - Segment colon
> - Use VTK to perform smoothing, triangulation
> - Calculate some features
> 
> Problem arise as soon as I'm loading in memory big CT scan (300 slices 
> and more).  When volume (CT slices) in memory (Windows task manager show 
> memory usage up to 600 Mb)... After applying segmentation memory usage 
> around 700 Mb (some bugs in standard library for deque container). 
> Computer has 1 Gb of the memory. Then I'm trying pass CT volume to VTK 
> algorithm and I recieve error message (something like segmentation fault 
> in Linux) where is written, that problems in vtkImaging... Part of the 
> code with VTK is:
> 
> vtkShortArray *shortArray = vtkShortArray::New();
> shortArray->SetArray(data,x_dim*y_dim*z_dim,1);
>  
> vtkImageData *imageData = vtkImageData::New();
> imageData->SetDimensions(x_dim,y_dim,z_dim);
> imageData->SetSpacing(x_res,y_res,z_res);
> imageData->SetScalarTypeToShort();
> imageData->GetPointData()->SetScalars(shortArray);
> 
> vtkImageGaussianSmooth *smoothVolume = vtkImageGaussianSmooth::New();
> smoothVolume->SetInput(imageData);
> smoothVolume->SetStandardDeviations(.5,.5,.18);
> smoothVolume->SetRadiusFactor(2.0);
> smoothVolume->SetDimensionality(3);
> smoothVolume->Update();
> 
> vtkContourFilter *contourFilter = vtkContourFilter::New();
> contourFilter->SetInput(smoothVolume->GetOutput());
> contourFilter->SetValue(0,surface_value);
> contourFilter->ComputeNormalsOff();
> contourFilter->ComputeGradientsOff();
> contourFilter->Update();
> 
> vtkWindowedSincPolyDataFilter *smoothMesh = 
> vtkWindowedSincPolyDataFilter::New();
> smoothMesh->SetInput(contourFilter->GetOutput());
> smoothMesh->SetNumberOfIterations(15);
> smoothMesh->SetPassBand(0.001);
> smoothMesh->Update();
> 
> .......
> 
> where
> 
> data - pointer to short (CT volume)
> x_dim, y_dim, z_dim - dimensions of the CT volume
> x_res, y_res, z_res - dimensions of the voxel (voxel resolution)
> 
> Program fall after calling method Update of the smoothVolume filter. 
> Memory usage at that moment > 1Gb (1.2 - 1.5 Gb). If this is a problem 
> of the memory allocation, how I can solve it in VTK ? if not a problem 
> of memory, then any other ideas ?
> 
> Thanks in advance and sorry for my English...
> 
> Ivan






More information about the vtkusers mailing list