1
votes

I try to extend an existing class (specifically NormalizedMutualInformation) in ITK by inserting an object of an existing class (GradientImageFilter) in order to study properly the image registration process. The problem is that i don't know how to access the image data from the template in order to insert them into the filter. What I did was to declare an typedef variable inside the NormalizedMutualInformation class:

typedef typename itk::GradientImageFilter FixedGradient;

which is the filter for the fixed image. But in the .hxx file (specifically in the Evaluate method) of the class when I tried to set the input data for the GradientImageFilter object, i used the template argument of the NormalizedMutualInformation class as an argument for the SetInput( ) method. It didn't work but i don't know what argument I should insert. How can I solve this problem?

1
Hey, if there is no processing before the point where you insert the GradientImageFilter, consider making a pipeline.El Marce

1 Answers

0
votes

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() );
}