The methods SetNumberOfInputs and SetNumberOfOutputs are deprecated, and using them does not ensure that the output objects are generated correctly before the filter processing is executed (causing lots of errors).
The reasons why these methods are now deprecated can be found in the ITKv4 migration guide (http://itk.org/migrationv4/index.php?action=artikel&cat=3&id=121&artlang=en&highlight=setnumberofoutputs).
These methods should be replaced by SetNumberOfIndexedInputs and SetNumberOfIndexedOutputs.