<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:36.0pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
.MsoPapDefault
        {mso-style-type:export-only;
        mso-margin-top-alt:auto;
        mso-margin-bottom-alt:auto;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:1526870339;
        mso-list-type:hybrid;
        mso-list-template-ids:-1856622388 201785359 201785369 201785371 201785359 201785369 201785371 201785359 201785369 201785371;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DE-AT link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-GB>Hi ITK Users,<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>I need some advice on memory management and speed. <o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>My system details: 64 bit windowsXP system and 4Gb RAM.<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>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).<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>I have to do some preprocessing too.<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>The pipeline is :<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>Original image -> discretegaussian -> gradientmagnitude -> HessianRecursiveGaussianImageFilter->symmetric eigenvalue analysis -> finally 3 vector image<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>For the above pipeline for a 100Mb image, i am running out of RAM.<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>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.<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>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<o:p></o:p></span></p><p class=MsoNormalCxSpLast><span lang=EN-GB>For hessianimageoutput, so by using streamfilter i thought i would be reaching 2.5Gm RAM but i reach approx 6Gb(virtual memory is used).<o:p></o:p></span></p><p class=MsoListParagraphCxSpFirst style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-GB>Am i doing something wrong with the stream filter ? (code given below)<o:p></o:p></span></p><p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-GB>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? <o:p></o:p></span></p><p class=MsoListParagraphCxSpMiddle style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-GB>Is there any other way to achieve speed vs RAM compromised solution?<o:p></o:p></span></p><p class=MsoListParagraphCxSpLast style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span lang=EN-GB><span style='mso-list:Ignore'>4.<span style='font:7.0pt "Times New Roman"'> </span></span></span><![endif]><span lang=EN-GB>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?<o:p></o:p></span></p><p class=MsoNormalCxSpFirst><span lang=EN-GB>Below is my code and after application of filter show the RAM usage:<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> char *infilename = "StreamTest.mhd"; <o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::CovariantVector<float,3> VectorPixelType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::Vector< VectorPixelType, 3 > EV_PixelType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> //Image type<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::Image<unsigned short, 3> InputImageType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::Image<float, 3> FloatImageType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::Image<EV_PixelType,3> EVImageType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB style='color:red'>**** RAM usage = 674Mb****<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> //reader initialisation and reading file<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::ImageFileReader<InputImageType> ReaderType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> ReaderType::Pointer reader = ReaderType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> reader->SetFileName( infilename );<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> reader->Update();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> InputImageType::Pointer inImage = reader->GetOutput();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB style='color:red'>**** RAM usage = 783Mb****<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::DiscreteGaussianImageFilter<InputImageType, FloatImageType> RGIFType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> RGIFType::Pointer gaussfilter = RGIFType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gaussfilter->SetInput(inImage);<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gaussfilter->SetVariance(4.0);<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gaussfilter->SetMaximumError(0.01);<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::CastImageFilter<FloatImageType,InputImageType> CIFType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> CIFType::Pointer castfilter = CIFType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> castfilter->SetInput(gaussfilter->GetOutput());<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::GradientMagnitudeImageFilter<InputImageType,FloatImageType> GMIFType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> GMIFType::Pointer gmfilter = GMIFType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gmfilter->SetInput(castfilter->GetOutput());<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gmfilter->Update();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> <o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> FloatImageType::Pointer gmImage = gmfilter->GetOutput();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB style='color:red'>**** RAM usage = 1290Mb****<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> gaussfilter->UnRegister();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'> castfilter->UnRegister();<o:p></o:p></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span style='color:red'> **** RAM usage = 1080Mb****<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><o:p> </o:p></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'> <span lang=EN-GB>typedef itk::HessianRecursiveGaussianImageFilter<FloatImageType> HessianRecursiveGaussianFilterType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef HessianRecursiveGaussianFilterType::OutputImageType HessianImageType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> HessianRecursiveGaussianFilterType::Pointer hessianfilter = HessianRecursiveGaussianFilterType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> hessianfilter->SetInput(gmImage);<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> hessianfilter->SetSigma(1);<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> typedef itk::StreamingImageFilter<HessianImageType,HessianImageType> StreamerType;<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> StreamerType::Pointer streamer = StreamerType::New();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> streamer->SetInput( hessianfilter->GetOutput() );<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> streamer->SetNumberOfStreamDivisions( 20 );<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB> streamer->Update();<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB style='color:red'>**** RAM usage = 3600Mb**** after few seconds it came to **** RAM usage = 6120Mb****<o:p></o:p></span></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt;text-autospace:none'><span lang=EN-GB><o:p> </o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>Thank you in advance.<o:p></o:p></span></p><p class=MsoNormalCxSpMiddle><span lang=EN-GB>Regards,<o:p></o:p></span></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>Kana Arunachalam Kannappan<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>Research Associate<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>FH OÖ Forschungs & Entwicklungs GmbH<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>Stelzhamer Strasse 23,<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>4600 Wels,<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>Austria.<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>Phone: +43 (0)7242 72811 -4420<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>kana.arunachalam@fh-wels.at<o:p></o:p></p><p class=MsoNormal style='margin:0cm;margin-bottom:.0001pt'>www.fh-ooe.at; www.3dct.at<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p></div></body></html>