[Insight-users] itkImageConvolutionImageFilter/itkGaussianImageSource Problem

Neil Panjwani paniwani at gmail.com
Thu May 26 09:28:52 EDT 2011


Not sure if you've seen this already, but it's a simpler example that should
work:

http://www.itk.org/Wiki/ITK/Examples/ImageProcessing/ConvolutionImageFilter

On Thu, May 26, 2011 at 5:04 AM, Krishnan V <v.srikrishnan at gmail.com> wrote:

>
> 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;
> }
>
> _____________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110526/16e631c0/attachment.htm>


More information about the Insight-users mailing list