[Insight-developers] What is the pipeline inside the itkGradientMagnitudeRecursiveGaussianImageFilter?

Xiaopeng Yang yxp233 at postech.ac.kr
Mon Dec 17 07:13:46 EST 2012


Dear All,

 

I am trying to look through the
itkGradientMagnitudeRecursiveGaussianImageFilter to figure out the pipeline
of this filter to visualize the computation process of image gradient
calculation from a CT volume dataset using this filter. However, the source
code of this filter makes me confused about the pipeline in this filter due
to my limited programming skill.

 

This filter consists of two major steps as far as I know: 1) image smoothing
using itkRecursiveGaussianImageFilter, and 2) image gradient calculation
using a finite difference method (Does anybody know what formula was used
for the finite difference method? I checked the source code but could not
get it). 

 

For step 1, I wrote a code to get the smoothed image. But I am not sure
whether my code would get the same smoothed image as
itkGradientMagnitudeRecursiveGaussianImageFilter or not. Please check my
code and point out which part I missed or is not correct.  Thank you very
much!

 

// Setup types

  typedef itk::Image< float,  3 >   FloatImageType;

  typedef itk::Image< unsigned char, 3 >   UnsignedCharImageType;

  typedef itk::ImageFileReader< FloatImageType >  readerType;

  typedef itk::RecursiveGaussianImageFilter<

                  FloatImageType, FloatImageType >  filterType;

  // Create and setup a reader

  readerType::Pointer reader = readerType::New();

  reader->SetFileName( "D:/Hybrid Method/Hybrid/LEJ/Diffusion_filter/3D.dcm"
);

  // Create and setup a gaussian filter

  filterType::Pointer m_DerivativeFilter = filterType::New();

  m_DerivativeFilter->SetInput( reader->GetOutput() );

  //m_DerivativeFilter->SetDirection(1); // "x" axis

  m_DerivativeFilter->SetFirstOrder();

  m_DerivativeFilter->SetSigma(1.3);

  m_DerivativeFilter->SetNormalizeAcrossScale(true);

  m_DerivativeFilter->ReleaseDataFlagOn();

  

  filterType::Pointer m_SmoothingFilters[2]; 

 

  for( unsigned int i = 0; i< 2; i++ )

  {

          m_SmoothingFilters[ i ] = filterType::New();

          m_SmoothingFilters[ i ]->SetZeroOrder();

          m_SmoothingFilters[ i ]->SetNormalizeAcrossScale( true ); 

          m_SmoothingFilters[ i ]->SetSigma( 1.3 );

  }

 

  m_SmoothingFilters[0]->SetInput( m_DerivativeFilter->GetOutput() );

 

  for( unsigned int i = 1; i< 2; i++ )

  {

          m_SmoothingFilters[ i ]->SetInput(
m_SmoothingFilters[i-1]->GetOutput() );

  }

  

  typedef itk::CastImageFilter< FloatImageType, UnsignedCharImageType >

                                                   CastFilterType;

 

 

  CastFilterType::Pointer caster1 = CastFilterType::New();

 

  caster1->SetInput( m_SmoothingFilters[1]->GetOutput() ); 

  

  typedef  itk::ImageFileWriter<  UnsignedCharImageType  > WriterType;

 

  WriterType::Pointer writer1 = WriterType::New();

 

  writer1->SetFileName( "RecusiveGaussian.dcm" );

 

  writer1->SetInput(caster1->GetOutput());

 

  writer1->Update();

 

 

return EXIT_SUCCESS;

 

Best regards,

Xiaopeng

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-developers/attachments/20121217/01324c5c/attachment.htm>


More information about the Insight-developers mailing list