[Insight-users] itkImageConvolutionImageFilter/itkGaussianImageSource Problem

Krishnan V v.srikrishnan at gmail.com
Thu May 26 09:53:56 EDT 2011


On Thu, May 26, 2011 at 7:08 PM, Neil Panjwani <paniwani at gmail.com> wrote:

> What are the dimensions of your kernel? They should be small like 3x3 in
> the example...

The kernel is much larger. i used the default of the itkGaussianImageSource
which gives a 32x32 or 64x64, certainly not 3x3.
Also, the even size of the kernel was not expected...

>
>
> On Thu, May 26, 2011 at 9:33 AM, Krishnan V <v.srikrishnan at gmail.com>wrote:
>
>>
>>
>> On Thu, May 26, 2011 at 6:58 PM, Neil Panjwani <paniwani at gmail.com>wrote:
>>
>>> 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
>>>
>>> Thanks for the reply. that works... my example does not.
>>
>>> 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/aa91c518/attachment.htm>


More information about the Insight-users mailing list