[ITK] Exception when running a filter inside an iteration loop

Nicolas Gallego nicgallego at gmail.com
Tue Jul 8 04:50:52 EDT 2014


Hi,

I am using a filter to process an image in an iterative process, so my code
looks like this

------------------------------------------------------------------------------------------------------------------------

    FilterType::Pointer filter = FilterType::New();

    filter ->SetSigma( 1.5 );

    filter ->SetField( reader1->GetOutput() );

    filter ->SetCertainty( reader2->GetOutput() );

    for (int i = 0; i < 2; i++ ) {

        try {

            filter->Update();

        } catch ( itk::ExceptionObject &exc ) {

            std::cerr << "Exception caught!" << std::endl;

            std::cerr << exc << std::endl;

            return -1;

        }

        VectorFieldType::Pointer tempField = filter->GetOutputField();

        ImageType::Pointer tempCert = filter->GetOutputCertainty();

        tempField->DisconnectPipeline();

        tempCert->DisconnectPipeline();

        filter->SetField( tempField );

        filter->SetCertainty( tempCert );

    }


------------------------------------------------------------------------------------------------------------------------


when I run it I get the exception after the update in the second iteration

---------------------------------------------------------------------------------------------------------------------------------
itk::ExceptionObject (0000000000A1EF70)
Location: "void __cdecl itk::Image<class
itk::Vector<float,3>,3>::Graft(const class itk::DataObject *)"
File:
d:\itk4.5\insighttoolkit-4.5.0\modules\core\common\include\itkImage.hxx
Line: 138
Description: itk::ERROR: Image(00000000033EC890): itk::Image::Graft()
cannot cast class itk::DataObject const * __ptr64 to class itk::Image<class
itk::Vector<fl
oat,3>,3> const * __ptr64

----------------------------------------------------------------------------------------------------------------------------------

anybody has ideas of what is it about?

I will extract an example code that reproduces the problem.

Thank you very much

Nicolás Gallego-Ortiz
Université catholique de Louvain, Belgium
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140708/183675e9/attachment-0001.html>


More information about the Community mailing list