[Insight-users] itkImageConvolutionImageFilter/itkGaussianImageSource Problem

Krishnan V v.srikrishnan at gmail.com
Thu May 26 05:04:17 EDT 2011


Hi all,
I am trying out the convolution image filter by generating a simple Gaussian
and convolving it with itself, ie, convolve a gaussian with itself. This is
done in 2D. I get an output which consists of two peaks at two ends of the
image along the X-axis.  This is obviously not the expected output. I have
attached a simple sample code.
Can someone faced a similar issue or help out with this?
thanks
krishnan
/************************************************************************************************************
*/
#include <itkImage.h>
#include <itkGaussianImageSource.h>
#include <itkConvolutionImageFilter.h>

typedef float PixelType;
typedef itk::Image<PixelType, 2> ImageType2D;
typedef itk::ImageFileReader<ImageType2D> Reader2D;
typedef itk::ImageFileWriter<ImageType2D> Writer2D;
void convolve_test(ImageType2D::Pointer input_image, ImageType2D::Pointer
kernel)
{
    typedef itk::ConvolutionImageFilter<ImageType2D,ImageType2D>
Convolver_Type;
    Convolver_Type::Pointer convolve = Convolver_Type::New();

    convolve->SetInput(kernel);
    convolve->SetImageKernelInput(kernel);
    convolve->Update();

    Writer2D::Pointer imwriter = Writer2D::New();
    imwriter->SetInput(convolve->GetOutput());
    imwriter->SetFileName("lenna.nii");
    imwriter->Update();
    return;
}
int main(int argc, char **argv)
{
  Writer2D::Pointer writer = Writer2D::New();
  ImageType2D::Pointer kernel;
  typedef itk::GaussianImageSource<ImageType2D> Gaussian_Generator_Type;
  Gaussian_Generator_Type::Pointer kernel_generator =
Gaussian_Generator_Type::New();
  double sigma[3];
  unsigned long size[3];
  double mean[3];

  Reader2D::Pointer imreader = Reader2D::New();
  imreader->SetFileName(argv[1]);
  imreader->Update();

  sigma[0] = 10.00; sigma[1] = 10.0;
  kernel_generator->SetSigma(sigma);

  kernel_generator->Update();
  kernel = kernel_generator->GetOutput();
  convolve_test( imreader->GetOutput(), kernel);
  /* Write the Gaussian */
  writer->SetFileName("Gaussian-1.nii");
  writer->SetInput(kernel);
  writer->Update();

  return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110526/fa505e15/attachment.htm>


More information about the Insight-users mailing list