Not sure if you've seen this already, but it's a simpler example that should work:<div><br></div><div><a href="http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter">http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter</a></div>
<div><br><div class="gmail_quote">On Thu, May 26, 2011 at 5:04 AM, Krishnan V <span dir="ltr"><<a href="mailto:v.srikrishnan@gmail.com">v.srikrishnan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<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>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>