[Insight-users] How to instantiate SparseFieldLevelSetImageFilter?

Valérie Duay valerie.duay at epfl.ch
Tue Feb 21 11:59:10 EST 2006


Hello,

In the description of SparseFieldLevelSetImageFilter it's written that 
we can use it directly by instantiating it. Could you give me an example 
showing how to do that?

I try something like below but that makes my program crash. I think the 
problem comes from LevelSetFunction.

    typedef itk::SparseFieldLevelSetImageFilter< ImageType, ImageType> 
SparseFieldFilterType;
    typedef itk::LevelSetFunction< ImageType > LevelSetFunctionType;
    LevelSetFunctionType::Pointer lsFunction = LevelSetFunctionType::New();
    SparseFieldFilterType::Pointer sparseField = 
SparseFieldFilterType::New();
    sparseField->SetInput(reinitLevelSet->GetOutput());
    sparseField->SetDifferenceFunction(lsFunction);
    sparseField->SetNumberOfIterations(100);
    sparseField->SetNumberOfLayers(3);
    sparseField->SetIsoSurfaceValue(0.0f);
    sparseField->Modified();
    
    //update=>crash!!!!
    try
    {
        sparseField->Update();
    }
    catch( itk::ExceptionObject & err )
    {
        cerr << "ExceptionObject caught !" << endl;
        cerr << err << std::endl;
        exit(0);
}

Thks,

Val



More information about the Insight-users mailing list