Copy output of nested filter to output of outer filter

Hello,

i want to copy the output of a nested filter to outer filter. The outer filter has the OutputImagePointer set (w.r. t. region, size, etc.) and I want to replace the output with the result from the nested filter. The images have the same size and PixelType. This looks similar to following code:

inside OuterFilter::GenerateData()
{
[…]
OutputImagePointer output = this->GetOutput();

[... other filter is running, m_OtherFilter is a member variable, it doesnt need to be in a pipeline]

this->m_OtherFilter->Update();
Output = this->m_OtherFilter->GetOutput(); // Now Output is the output from OtherFilter->GetOutput()
}

If I call OuterFilter->GetOutput() later on it will return the OutputImagePointer that was set before the OuterFilter::GenerateData() call.

How do I get the output from the outer filter to be replaced by the output from the inner filter?
If more informations needed please ask. Thank you in advance.

Sincerly,
Gordian

Edit: Moved topic to Uncategorized because no explicit Algorithm is discussed.

Found a possible way to resolve this.
If you set the output in the superclass then it will work:

{
[…]
Output = this->m_OtherFilter->GetOutput(); // Now Output is the output from OtherFilter->GetOutput()
this->Superclass::SetPrimaryOutput(Output);
}

i am not sure if this will fix it but at least the image from the nested filter is the output of the outer filter.

I am not sure what you are doing. I need a large example to under stand better to help. I’d recommend creating a small example to share what you are trying to do and the problem you have encountered.

The method you might be looking for is Graft. You can search for examples of how to use it.

It was the Graft() method I was looking for.
Thank you.
The example for the minipipeline was very helpful.

2 Likes