[Insight-users] WG: Pipeline problems: How to delete input data after calculation

Luis Ibanez luis.ibanez at kitware.com
Thu Apr 8 15:23:04 EDT 2010


Hi Gerald,

You may want to try


         TFilter1->ReleaseDataFlagOn()


and..., another option is to try to use InPlace filters,
(if possible).


That said, your method of creating filters in a local
scope, running them, capturing the output and
destroying the filter, should work just as well.

It is not the "pipeline-way" of doing things but it
should help you with the memory restrictions.



    Regards,


          Luis


-------------------------------------------
On Thu, Apr 8, 2010 at 6:12 AM, Lodron, Gerald
<Gerald.Lodron at joanneum.at> wrote:
>
> Hi
>
> Since i have a lot of memory problems i try to release my data of the front pipline elements and do not exactly know how to do that, my example (pseudo code, may not work):
>
> //Typedefs
> Typedef Itk::ImageReader<Type> Treader;
> Typedef itk::ImageFilter1<Type, Type> TFilter1;
> Typedef itk::ImageFilter2<Type, Type> TFilter2;
> Typedef itk::ImageWriter<Type> Twriter;
>
> //Create Instances
> Treader::Pointer oReader = Treader::New();
> TFilter1::Pointer oFilter1 = TFilter1::New();
> TFilter2::Pointer oFilter2 = TFilter2::New();
> Treader::Pointer oWriter = Treader::New();
>
> //Settings
> oReader->SetFileName("InImage.mha");
> oWriter->SetFileName("OutImage.mha");
>
> //Pipeline
> oFilter1->SetInput(oReader->GetOutput());
> oFilter2->SetInput(oFilter1->GetOutput());
> oWriter->SetInput(oFilter2->GetOutput());
>
> The programm works but i think here I need the memory of InImage.mha three times:
> - First after reader
> - Second after Filter1
> - Third after Filter2
>
> I want to do the following:
> - First load Image on memory
> - Calculate result of Filter1, release memory of reader
> - Calculate result of Filter2, release memory of filter1
>
> Now i need the memory only one time. It is not allowed to call the delete function of the process objects so how can i tell the smart pointers to relese that stuff, currently i make the following strange thing:
>
> //Typedefs
> Typedef Itk::ImageReader<Type> Treader;
> Typedef itk::ImageFilter1<Type, Type> TFilter1;
> Typedef itk::ImageFilter2<Type, Type> TFilter2;
> Typedef itk::ImageWriter<Type> Twriter;
>
> Itk::Image<Type>::Pointer oPointer;
>
> {
>        Treader::Pointer oReader = Treader::New();
>        oReader->SetFileName("InImage.mha");
>        oReader->Update();
>        oPointer = oReader->GetOutput();
>        oPointer->DisconnectPipeline();
> }
> {
>        TFilter1::Pointer oFilter1 = TFilter1::New();
>        oFilter1->SetInput(oPointer);
>        oFilter1->Update();
>        oPointer = oFilter1->GetOutput();
>        oPointer->DisconnectPipeline();
> }
> {
>        TFilter2::Pointer oFilter2 = TFilter2::New();
>        oFilter2->SetInput(oPointer);
>        oFilter2->Update();
>        oPointer = oFilter2->GetOutput();
>        oPointer->DisconnectPipeline();
> }
>
> {
>        Treader::Pointer oWriter = Treader::New();
>        oWriter ->SetInput(oPointer);
>        oWriter->SetFileName("OutImage.mha");
>        oWriter->Update();
> }
>
> Better suggestions?
>
> _____________________________________
> 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
>


More information about the Insight-users mailing list