I’m working with ITK 5.2.1. I created a 2-input filter that subclasses BinaryGeneratorImageFilter. It is instantiated with three separate template types: BinaryGeneratorImageFilter<TIn1, TIn2, Tout>.
Inside my filter, I wanted to get the second input. I did not find a function named “GetInput2()” available, so I tried “this->GetInput(1)” and discovered that it returns the first type, TIn1. Digging through code, I came across code that works with my testing so far:
For this filter the “watch outs” are that indexed input 0 and 1 could be an image or a constant. Also indexed input 0 is called input 1 and indexed input 1 is called input 2 in the member functions. However these indexed inputs don’t have a “name” per the ProcessObject named object book keeping.
These oddities with the naming is for compatibility with the BinaryFunctorImageFilter.
Since both inputs can be a constant or an image there is not a single return type that GetInput1 ( if it would be implemented) could return. You can see how that is implemented and used here:
It is important to check the results of the dynamic cast to determine if the input might not be an image and may be a constant.
Lastly, if you need to access these input images and are not just configuring a lambda or a functor the usage may be outside of the original design of the filter.
Truthfully, I probably am mis-using the filter slightly and should just correct my code. Basically, I am treating the second input as optional. I had originally written a filter to compute on an entire image and decided later I needed to use a binary image as a mask to constrain which pixels are involved in the computation. I am checking the second input to see if a mask is available.