xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XForms] image convolution


From: alessandro basili
Subject: [XForms] image convolution
Date: Thu, 26 Apr 2012 18:01:08 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

Dear all,

I'm writing an application to display an image and do some processing on
it. Since the images are severely affected by 'salt and pepper noise' I
wanted to use a gaussian filter to get rid of it.

Once I defined the kernel I wanted to use the flimage_convolve function,
but apparently I get segmentation fault.
What looks to me strange in the function is that a variable /weight/ is
calculated out of the kernel but in the following way:

>     for (weight = i = 0; i < kcol * krow; i++)
>         weight += kernel[0][i];

where kcol and krow are the columns and rows of the kernel. Since the
kernel is allocated with fl_get_matrix function the variable /i/ will
certainly go beyond the array dimensions.

Is this a potential problem or I'm missing something?

By the way, my pseudo code is the following:
> 
> int kcol = 5, krow = 5;
> int **kernel = fl_get_matrix(kcol, krow, sizeof(**kernel));
> 
> init_kernel(kernel, "gaussian", kcol, krow);
> flimage_convolve(im, kernel, kcol, krow);
> flimage_display(im, FL_ObjWin(CANVAS));

Any comment is appreciated,

Al



reply via email to

[Prev in Thread] Current Thread [Next in Thread]