[Insight-users] 1D Convolution with Gaussian Kernel using

Cory Quammen cquammen at cs.unc.edu
Wed Nov 16 11:28:27 EST 2011


Antonio,

It looks like you are defining your kernel to be 256x256, not 256x1.
You probably want to call

size[0] = width;
size[1] = 1;

instead of

size.Fill(width);

You might want to consider using the GaussianImageSource
(http://www.itk.org/Doxygen/html/classitk_1_1GaussianImageSource.html)
to generate your Gaussian.

Hope that helps,
Cory

2011/11/16 Antonio Gómez Barquero <agb1 at alu.upct.es>:
> SORRY, the last e-mail was icomplete, here is ok:
>
>
>
> My goal is to calculate the calculation in each row of a 2D-image ( in the
> x-direction)
>
> After following the tip from Cory I am trying to use the
> ‘ConvolutionImageFilter’, and make a kernel with the Gaussian values I
> calculate before.
>
> I took a look to this example
> (http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter)
> and my question is how to include the values of the Gaussian filter to the
> kernel, I tried wit the code below and it compiles, but it seems the
> execution has no end when I update the convolutionFilter… Because of that I
> think that I am doing something wrong. My code is below and is not so much,
> if some can give some help I would appreciate that really a lot !!!!.
>
>
>
>       typedef itk::ConvolutionImageFilter <ImageType> ConvFilterType;
>
>
>
>       ImageType::Pointer kernel = ImageType::New();
>
>       CreateKernel(kernel, Gaussian , 256);
>
>
>
>       //Convolve image with kernel
>
>       ConvFilterType::Pointer convolutionFilter = ConvFilterType::New();
>
>       convolutionFilter->SetInput(Li_itk);
>
>       convolutionFilter->SetImageKernelInput(kernel);
>
>       convolutionFilter->Update();
>
>
>
> void Reg_image_v2::CreateKernel(Reg_image_v2::ImageType::Pointer kernel,
> double *Gaussian, unsigned int width) {
>
>
>
>       ImageType::IndexType start;
>
>       start.Fill(0);
>
>       ImageType::SizeType size;
>
>       size.Fill(width);
>
>       ImageType::RegionType region;
>
>       region.SetSize(size);
>
>       region.SetIndex(start);
>
>       kernel->SetRegions(region);
>
>       kernel->Allocate();
>
>
>
>       ImageType::IndexType pixelIndex;
>
>       for (int i = 0 ; i < width ; i ++){
>
>             pixelIndex[0] = i ;
>
>             pixelIndex[1] = 0 ;
>
>             kernel->SetPixel(pixelIndex,Gaussian[i]);
>
>       }
>
>       itk::ImageRegionIterator<ImageType> imageIterator(kernel, region);
>
>    while(!imageIterator.IsAtEnd())
>
>     {
>
>     //imageIterator.Set??
>
>     ++imageIterator; //operator++  increments the iterator one position in
> the positive direction
>
>     }
>
>
>
>
>
> } // end createKernel
>
>
>
>
>
> 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
>
>



-- 
Cory Quammen
Research Associate
Department of Computer Science
The University of North Carolina at Chapel Hill


More information about the Insight-users mailing list