[Insight-users] Memory management

Sergio Vera sergio.vera at alma3d.com
Fri Mar 18 04:46:27 EDT 2011


Hello, Kana,
I might be wrong but as far as I remember, the filters related with
RecursiveGaussian aren't compatible with the streaming filter :(

Regards

On Thu, Mar 17, 2011 at 11:54 PM, Arunachalam Kana <
Kana.Arunachalam at fh-wels.at> wrote:

> Hi ITK Users,
>
> I need some advice on memory management and speed.
>
> My system details: 64 bit windowsXP system and 4Gb RAM.
>
> My goal: To obtain eigen vectors for 100Mb unsigned short image. Eigen
> vectors not for the whole image but for certain regions (approx occupies 40%
> of image).
>
>
>
> I have to do some preprocessing too.
>
> The pipeline is :
>
> Original image -> discretegaussian -> gradientmagnitude ->
> HessianRecursiveGaussianImageFilter->symmetric eigenvalue analysis ->
> finally 3 vector image
>
> For the above pipeline for a 100Mb image, i am running out of RAM.
>
> After reading itkmails, i decided to use streamfilter to stream part of the
> image so that the RAM usage is low. I only tested half way and the RAM was
> overloaded.
>
>
>
> I am using streamimagefilter to reduce the memory usage. After calculation
> of gradientmagnitude i have used 1.08Gb RAM. After this i need 1.2Gb RAM
>
> For hessianimageoutput, so by using streamfilter i thought i would be
> reaching 2.5Gm RAM but i reach approx 6Gb(virtual memory is used).
>
> 1.       Am i doing something wrong with the stream filter ? (code given
> below)
>
> 2.       I tried another option: As i do not need hessian for the whole
> image, I used discretehessianfunction for hessian calculation but it is 30
> times slower that the recursivehessian. Is discretegaussianimagefunction
> multithreaded?
>
> 3.       Is there any other way to achieve speed vs RAM compromised
> solution?
>
> 4.       The 100Mb data set is test data. The real data is 10Gb for which
> i will use 64 bit linux system (opensuse 11.2) . will the pipeline be
> executed in linux too?
>
> Below is my code and after application of filter show the RAM usage:
>
>
>
>   char *infilename = "StreamTest.mhd";
>
>   typedef itk::CovariantVector<float,3> VectorPixelType;
>
>   typedef itk::Vector< VectorPixelType, 3 > EV_PixelType;
>
>
>
>   //Image type
>
>   typedef itk::Image<unsigned short, 3>              InputImageType;
>
>   typedef itk::Image<float, 3>                       FloatImageType;
>
>   typedef
> itk::Image<EV_PixelType,3>
> EVImageType;
>
> **** RAM usage = 674Mb****
>
>   //reader initialisation and reading file
>
>   typedef itk::ImageFileReader<InputImageType>
> ReaderType;
>
>   ReaderType::Pointer reader = ReaderType::New();
>
>   reader->SetFileName( infilename );
>
>   reader->Update();
>
>   InputImageType::Pointer inImage = reader->GetOutput();
>
>
>
> **** RAM usage = 783Mb****
>
>   typedef itk::DiscreteGaussianImageFilter<InputImageType, FloatImageType>
> RGIFType;
>
>   RGIFType::Pointer gaussfilter = RGIFType::New();
>
>   gaussfilter->SetInput(inImage);
>
>   gaussfilter->SetVariance(4.0);
>
>   gaussfilter->SetMaximumError(0.01);
>
>
>
>   typedef itk::CastImageFilter<FloatImageType,InputImageType> CIFType;
>
>   CIFType::Pointer castfilter = CIFType::New();
>
>   castfilter->SetInput(gaussfilter->GetOutput());
>
>
>
>   typedef itk::GradientMagnitudeImageFilter<InputImageType,FloatImageType>
> GMIFType;
>
>   GMIFType::Pointer gmfilter = GMIFType::New();
>
>   gmfilter->SetInput(castfilter->GetOutput());
>
>   gmfilter->Update();
>
>
>
>   FloatImageType::Pointer gmImage = gmfilter->GetOutput();
>
> **** RAM usage = 1290Mb****
>
>
>
>   gaussfilter->UnRegister();
>
>   castfilter->UnRegister();
>
>   **** RAM usage = 1080Mb****
>
>
>
>   typedef itk::HessianRecursiveGaussianImageFilter<FloatImageType>
> HessianRecursiveGaussianFilterType;
>
>   typedef HessianRecursiveGaussianFilterType::OutputImageType
> HessianImageType;
>
>   HessianRecursiveGaussianFilterType::Pointer hessianfilter =
> HessianRecursiveGaussianFilterType::New();
>
>   hessianfilter->SetInput(gmImage);
>
>   hessianfilter->SetSigma(1);
>
>
>
>   typedef itk::StreamingImageFilter<HessianImageType,HessianImageType>
> StreamerType;
>
>   StreamerType::Pointer streamer = StreamerType::New();
>
>   streamer->SetInput( hessianfilter->GetOutput() );
>
>   streamer->SetNumberOfStreamDivisions( 20 );
>
>   streamer->Update();
>
> **** RAM usage = 3600Mb**** after few seconds it came to **** RAM usage =
> 6120Mb****
>
>
>
> Thank you in advance.
>
> Regards,
>
> Kana Arunachalam Kannappan
>
> Research Associate
>
> FH OÖ Forschungs & Entwicklungs GmbH
>
> Stelzhamer Strasse 23,
>
> 4600 Wels,
>
> Austria.
>
> Phone: +43 (0)7242 72811 -4420
>
> kana.arunachalam at fh-wels.at
>
> www.fh-ooe.at; www.3dct.at
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>


-- 
Sergio Vera

 Alma IT Systems
 C/ Vilana, 4B, 4º 1ª
 08022 Barcelona
 T. (+34) 932 380 592
 www.alma3d.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110318/4f70e806/attachment.htm>


More information about the Insight-users mailing list