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

Lodron, Gerald Gerald.Lodron at joanneum.at
Thu Apr 8 06:09:46 EDT 2010


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();




TFilter2::Pointer oFilter2 = TFilter2::New();
Treader::Pointer oWriter = Treader::New();

//Settings
oReader->SetFileName("InImage.mha");
oWriter->SetFileName("OutImage.mha");

//Pipeline

oFilter2->SetInput(oFilter1->GetOutput());
oWriter->SetInput(oFilter2->GetOutput());








More information about the Insight-users mailing list