I think you can achieve this by writing a composite filter. You can have more information about it in the ITK software guide: http://www.itk.org/ItkSoftwareGuide.pdf
Read chapter 8, section 6.
Basically, you must create a NEW filter class, then you must build the pipeline in the constructor of your filter. In your case it would be a pipeline composed of the GradientImageFilter and then the NormalizedMutualInformation. The input to this new filter should be passed to the gradient filter and the output taken from the normalizedmutual as the manual says: "The input and output of the composite filter need to be grafted on to the head and tail (respectively)
of the component filters.")
Here is a complete code example: http://www.itk.org/Doxygen46/html/Filtering_2CompositeFilterExample_8cxx-example.html
Interesting parts of the example are the composite filter's constructor where the pipeline's assembly takes part:
template <class TImageType>
CompositeExampleImageFilter<TImageType>
::CompositeExampleImageFilter()
{
m_Threshold = 1;
m_GradientFilter = GradientType::New();
m_ThresholdFilter = ThresholdType::New();
m_ThresholdFilter->SetInput( m_GradientFilter->GetOutput() );
m_RescaleFilter = RescalerType::New();
m_RescaleFilter->SetInput( m_ThresholdFilter->GetOutput() );
m_RescaleFilter->SetOutputMinimum(
NumericTraits<PixelType>::NonpositiveMin());
m_RescaleFilter->SetOutputMaximum(NumericTraits<PixelType>::max());
}
and then the GenerateData
method where the magic happens:
template <class TImageType>
void
CompositeExampleImageFilter<TImageType>::
GenerateData()
{
m_GradientFilter->SetInput( this->GetInput() );
m_ThresholdFilter->ThresholdBelow( this->m_Threshold );
m_RescaleFilter->GraftOutput( this->GetOutput() );
m_RescaleFilter->Update();
this->GraftOutput( m_RescaleFilter->GetOutput() );
}
GradientImageFilter
, consider making a pipeline. – El Marce