[Insight-users] GradientFilterType not working as expected
Antonio Gómez Barquero
agb1 at alu.upct.es
Tue Jan 17 04:31:09 EST 2012
Hi,
I am not using the 'RecursiveGaussianFilter' neither the
'discretegaussianimagefilter'. I am using the 'GradientImageFilter'
,declared in the header file as follows:
typedef double operatorValueType ;
typedef double outputValueType ;
typedef double InputPixelType ;
typedef itk::Image < InputPixelType , 2 > InputImageType ;
typedef itk::GradientImageFilter < InputImageType ,
operatorValueType , outputValueType > GradientFilterType ;
And creating the filter in the main file:
GradientFilterType::Pointer gradientFilter =
GradientFilterType::New();
I think there is a problem in the code I posted before because I have used
this methodology other times and it works always perfectly...
Thanks for your reply.
Antonio
De: cagatay bilgin [mailto:bilgincc at gmail.com]
Enviado el: lunes, 16 de enero de 2012 20:10
Para: Antonio Gómez Barquero
CC: insight-users at itk.org
Asunto: Re: [Insight-users] GradientFilterType not working as expected
Hi Antonio,
I think what you are experiencing could be a result
of the RecursiveGaussianFilter. This filter is fast and
gives an ``approximation" (either the manual or the webpage
has links to the paper that the filter implements). If you want
more accurate but possibly slower results try the discrete
gaussian filter. You can set the maximum error for your
gradients using discretegaussianimagefilter.
Regards,
Cagatay
2012/1/16 Antonio Gómez Barquero <agb1 at alu.upct.es>
Hi all,
I am calculating the typical registration example from one white point to
the letter 'C' over a black background.
In the first iteration of my program ( numiter = 1 ), it calculates the
gradient from a 'reader' and the result is correct. In the next iteration (
numiter = 2 ) the result is not completely correct, in the borders of the
image there are some wrong values, despite the gradient values in the centre
of the image are correct.
Below is my code, I really need to fix this problem soon and I have spent
some days without results! Any help would be really nice.
double *dT1 = new double[ancho*alto]; // width * height
double *dT2 = new double[ancho*alto]; // width * height
// Definition of the input image container and output(gradient)
GradientFilterType::Pointer gradientFilter = GradientFilterType::New();
ImageType::Pointer im_T = ImageType::New();
if (numIter == 1){ // The first time read image from reader
gradientFilter->SetInput(reader_T->GetOutput());
}
else {
// Definition of the basic parameters of the image that contents
the input data
ImageType::IndexType start;
start[0] = 0 ; // first index on X
start[1] = 0 ; // first index on Y
ImageType::SizeType size;
size[0] = ancho; // size along X
size[1] = alto ; // size along Y
ImageType::RegionType region;
region.SetSize(size);
region.SetIndex(start);
im_T->SetRegions(region);
im_T->Allocate(); // allocate the image
double2itk ( T , &im_T); // T(double*) --> im_T(itk::Image)
gradientFilter->SetInput(im_T);
}
// Common part
gradientFilter->SetUseImageSpacingOff(); // for derivation in
isotropic pixel space
gradientFilter->Update();
SelectionFilterType::Pointer componentExtractor_x =
SelectionFilterType::New();
SelectionFilterType::Pointer componentExtractor_y =
SelectionFilterType::New();
componentExtractor_x->SetIndex(0);// componente x
componentExtractor_y->SetIndex(1);// componente y
componentExtractor_x->SetInput(gradientFilter->GetOutput());
componentExtractor_y->SetInput(gradientFilter->GetOutput());
componentExtractor_x->Update();
componentExtractor_y->Update();
dT2 = itk2double(componentExtractor_x->GetOutput(),dT2,ancho,alto); //
X-Component of the gradient
dT1 = itk2double(componentExtractor_y->GetOutput(),dT1,ancho,alto);
// Y-Component of the gradient
Thanks!
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/]
UPCT (Universidad Politécnica de Cartagena)[ http://www.upct.es/]
_____________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.html
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.itk.org/mailman/listinfo/insight-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120117/9b45a176/attachment.htm>
More information about the Insight-users
mailing list