<br>Hi all,<br>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. <br>
Can someone faced a similar issue or help out with this? <br>thanks<br>krishnan<br>/************************************************************************************************************ */<br>#include <itkImage.h><br>
#include <itkGaussianImageSource.h><br>#include <itkConvolutionImageFilter.h><br><br>typedef float PixelType;<br>typedef itk::Image<PixelType, 2> ImageType2D;<br>typedef itk::ImageFileReader<ImageType2D> Reader2D;<br>
typedef itk::ImageFileWriter<ImageType2D> Writer2D;<br>void convolve_test(ImageType2D::Pointer input_image, ImageType2D::Pointer kernel)<br>{<br> typedef itk::ConvolutionImageFilter<ImageType2D,ImageType2D> Convolver_Type;<br>
Convolver_Type::Pointer convolve = Convolver_Type::New();<br><br> convolve->SetInput(kernel);<br> convolve->SetImageKernelInput(kernel);<br> convolve->Update();<br><br> Writer2D::Pointer imwriter = Writer2D::New();<br>
imwriter->SetInput(convolve->GetOutput());<br> imwriter->SetFileName("lenna.nii");<br> imwriter->Update();<br> return;<br>}<br>int main(int argc, char **argv)<br>{<br> Writer2D::Pointer writer = Writer2D::New();<br>
ImageType2D::Pointer kernel;<br> typedef itk::GaussianImageSource<ImageType2D> Gaussian_Generator_Type;<br> Gaussian_Generator_Type::Pointer kernel_generator = Gaussian_Generator_Type::New();<br> double sigma[3];<br>
unsigned long size[3];<br> double mean[3];<br><br> Reader2D::Pointer imreader = Reader2D::New();<br> imreader->SetFileName(argv[1]);<br> imreader->Update();<br><br> sigma[0] = 10.00; sigma[1] = 10.0;<br> kernel_generator->SetSigma(sigma);<br>
<br> kernel_generator->Update();<br> kernel = kernel_generator->GetOutput();<br> convolve_test( imreader->GetOutput(), kernel);<br> /* Write the Gaussian */<br> writer->SetFileName("Gaussian-1.nii");<br>
writer->SetInput(kernel);<br> writer->Update();<br> <br> return 0;<br>}<br>