[Insight-developers] What if a Filter have input == output ?

Will Schroeder will.schroeder at kitware.com
Thu Sep 21 14:50:31 EDT 2000


Hi Luis-

It is possible but dangerous. The problem is that if the input to a filter actually serves as the input to many filters, and that one filter modified its input, how do the others know about it and what happens to them? Of course this is less of a problem if the pipeline does not branch.

One approach is that the input be treated as read-only. Using reference counting you can pass input pieces to the output if nothing changes (this is more useful in itkMesh where the class is made up of several containers). 

On the other hand, Ken Martin has suggested this clever approach. When you ask for input, and the input reference count is 1, and the ReleaseData flag is on, then every filter is allowed to write onto its input. Otherwise, a copy of the input is made and passed to the filter. (ReleaseData is a flag that tells the filters to discard their data when done with it. If ReleaseData is off, all filters retain copies of their output. Keeping copies of the output limits the amount of reexecution at the expense of memory.)

What do others think?

Will

At 10:56 AM 9/21/00 -0400, Luis Ibanez wrote:

>Hi,
>
>Is it possible to use an image as input
>and output of a filter at the same time ?
>
>-------





More information about the Insight-developers mailing list