[Insight-users] itkImageConvolutionImageFilter/itkGaussianImageSource Problem

Luis Ibanez luis.ibanez at kitware.com
Sun May 29 17:41:56 EDT 2011


Hi Krishnan,

You found indeed a bug in the itkConvolutionImageFilter class.

We just logged a bug entry in the tracker:
http://public.kitware.com/Bug/view.php?id=12236

The attached file, (a modified version of yours)
more clearly illustrates the problem.

When using a Kernel of even size (e.g. 32) the
output convolved image has a diagonal shift.


This should be fixed soon in ITK4.


    Thanks


         Luis


----------------------------------------
On Thu, May 26, 2011 at 9:53 AM, Krishnan V <v.srikrishnan at gmail.com> wrote:
>
>
> 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
>>>>>
>>>>
>>>
>>
>
>
> _____________________________________
> 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 --------------
A non-text attachment was scrubbed...
Name: convolve.cxx
Type: text/x-c++src
Size: 2329 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110529/6353a200/attachment.cxx>


More information about the Insight-users mailing list