[ITK] DisconnectPipeline() on multiple output filter
Nicolas Gallego
nicgallego at gmail.com
Mon Jul 14 09:56:12 EDT 2014
Hi Brad, thank you very much, it works!
I had reimplemented the MakeOutput method in my filter but with a sligthly
different signature, and it called twice the .GetPointer() method on the
output, so I changed it and it seams to solve the problem.
// class template stuff...
void
//MakeOutput( unsigned int idx )
::MakeOutput( DataObjectPointerArraySizeType idx )
{
DataObject::Pointer output;
switch ( idx ) {
case 0:
output = ( TVectorField::New() ).GetPointer();
break;
case 1:
output = (TImage::New() ).GetPointer();
break;
default:
std::cerr << "No output " << idx << std::endl;
output = NULL;
break;
}
// return output.GetPointer();
return output;
}
Nicolás Gallego-Ortiz
Université catholique de Louvain, Belgium
2014-07-14 15:22 GMT+02:00 Bradley Lowekamp <blowekamp at mail.nih.gov>:
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20140714/6ad059a3/attachment-0002.html>
More information about the Community
mailing list