[Insight-users] GradientFilterType not working as expected

Antonio Gómez Barquero agb1 at alu.upct.es
Mon Jan 16 05:17:28 EST 2012


 

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/>
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/20120116/b3bdd8a1/attachment.htm>


More information about the Insight-users mailing list