[Insight-users] Erroneous Results calculating the gradient of an image with ITK

Antonio Gómez Barquero agb1 at alu.upct.es
Wed Sep 28 07:59:30 EDT 2011


Erroneous Results calculating the gradient of an image with ITK


 

In the header file, I declare all of this types, The “Gradient ImageFilter”
is for calculate the gradient of a 2D image, and the
“VectorIndexSelectionCastImageFilter” is for selecting the ’x’ and ‘y’
component of the gradient calculating, due to the fact that the result of
computing th gradient is a vector image.

 

typedef double                               operatorValueType;

typedef double                               outputValueType;

typedef double                               InputPixelType;

typedef  itk::Image<InputPixelType, 2> InputImageType;

typedef  itk::GradientImageFilter< InputImageType, operatorValueType,
outputValueType> GradientFilterType;

                //for extracting a scalar from the vector image

typedef double                               OutputPixelTypeImage;

typedef double                               ComponentType;

typedef  itk::CovariantVector<ComponentType,2> OutputPixelType;

typedef  itk::Image <OutputPixelType, 2> OutputImageType;

typedef
itk::VectorIndexSelectionCastImageFilter<OutputImageType,InputImageType>
SelectionFilterType; // < intputType , outputType>

 

After the declarations, the main part of interest of the code is below:

 

GradientFilterType::Pointer gradientFilter = GradientFilterType::New();

gradientFilter->SetInput(T_g->GetOutput());  // From T_g (is a reader) comes
the image

gradientFilter->Update();

                

SelectionFilterType::Pointer componentExtractor_x =
SelectionFilterType::New();

SelectionFilterType::Pointer componentExtractor_y =
SelectionFilterType::New();

 

componentExtractor_x->SetIndex(0);// x component of the gradient

componentExtractor_y->SetIndex(1);// y component of the gradient

 

componentExtractor_x->SetInput(gradientFilter->GetOutput());

componentExtractor_y->SetInput(gradientFilter->GetOutput());

 

componentExtractor_x->Update();

componentExtractor_y->Update();

 

It seems that everything works fine, but the problem is that when I read the
image and I compare it with the calculation of the gradient in Matlab (which
I assume to be correct) the results are completely different
Anyone has used
before the “VectorIndexSelectionCastImageFilter” and see something strange?
Or in the process of calculating the gradient?

 

Thanks so much!

 

Antonio Gómez Barquero

 

Ingeniero de Telecomunicaciones -Becario Investigador asociado a Actividades
de I+D+I 

GTTS ( Grupo de Tratamiento y Teoría de la Señal)[  <http://gtts.upct.es/>
http://gtts.upct.es/]

UPCT (Universidad Politécnica de Cartagena)[  <http://www.upct.es/>
http://www.upct.es/]

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110928/374e03ee/attachment.htm>


More information about the Insight-users mailing list