[ITK] DisconnectPipeline() on multiple output filter

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Jul 14 09:22:24 EDT 2014


Hello,

Did you overload the MakeOutput method for your filter?

This method is used to create new outputs, like when you disconnect the output. If you want to understand how this is done look here at the DataObject::DisconnectPipeline method[1], which calls ProcessObject::SetOutput(NULL)[2], and then your overridden ProcessObject::MakeOutput such as here [3].

Brad

[1] https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkDataObject.cxx#L202-L223
[2] https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Core/Common/src/itkProcessObject.cxx#L482-L484
[3] https://github.com/InsightSoftwareConsortium/ITK/blob/master/Modules/Filtering/DistanceMap/include/itkDanielssonDistanceMapImageFilter.hxx#L52-L70

On Jul 14, 2014, at 9:09 AM, Nicolas Gallego <nicgallego at gmail.com> wrote:

> Hi,
> 
> I have implemented a filter with two outputs of different type inspired by the example []. This filter is used inside a loop, so I learned from an earlier post in this list that I should call the method DisconnectPileline() on the image pointers I use hold the intermediate results before using them as inputs of my pipeline on the next iteration. Something like this
> 
> .....
> TImage1::Pointer im1;
> TImage2::Pointer im2;
> 
> ... initialization code...
> filter->SetInput1( im1 );
> filter->SetInput2( im2 );
> 
> for( int i = 0; i < nIter; i++) {
>     filter->Update();
>     TImage1::Pointer tmp1 = filter->GetOutput1();
>     TImage2::Pointer tmp2 = filter->GetOutput2();
> 
> 
> 
> 
> The problem is that it only works on the principal output, when I call the method on the second output, I get the following execution error,
> 
> ---------------------------------------------------------------------------------------------------------------------------
> itk::ExceptionObject (0000000000ACF300)
> Location: "unknown"
> File: d:\itk4.5\insighttoolkit-4.5.0\modules\core\common\include\itkImage.hxx
> Line: 138
> Description: itk::ERROR: Image(0000000002FDBDF0): itk::Image::Graft() cannot cast class itk::DataObject const * __ptr64 to class itk::Image<class itk::Vector<fl
> oat,3>,3> const * __ptr64
> ---------------------------------------------------------------------------------------------------------------------------
> 
> and when I use PipelineDisconnect() only on the principal output, my pipeline is Updated twice as it is still connected, and the program does not crash but the results are numerically incorrect. Any ideas to solve this issue? I know I should submit an example code that reproduces the error, I will try to extract it and post it later, but for the moment I would be happy to get some ideas about how to debug this issu.
> 
> Thank you very much,
> 
> Nicolás Gallego-Ortiz
> Université catholique de Louvain, Belgium
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community




More information about the Community mailing list