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