import numarray.nd_image numarray.nd_image.gaussian_filter1d( ( 0.0, 1.0, 0.0 ), 1, order = 1, axis = 0, mode = 'constant' ) array([0.24197145, 0. , 0.24197145])
when it should be [ 0.24197145, 0. , 0.24197145]) (notice the change in
Hi. I think I found a bug in gaussian_filter1d. roughly the function creates a 1d kernel and then calls correlate1d. The problem I see is that the kernel should be mirrored prior to calling correlate1d since we want to convolve, not correlate. as a result: the sign of coefficients) Or did I get that wrong? alex.
I think you are correct: The result of a gaussian filter of order one should be a derivative operator. Thus the response to an array created with arange() should be close to one (barring edge effects). Currently we have:
from numarray import * from numarray.nd_image import gaussian_filter a = arange(10, type = Float64) gaussian_filter(a, 1.0, order = 1) array([0.36378461, 0.84938238, 0.98502645, 0.99939268, 0.999928 , 0.999928 , 0.99939268, 0.98502645, 0.84938238, 0.36378461])
So the sign is wrong, that can be fixed by mirroring the gaussian kernels. I have done so in CVS. The same holds true for the Sobel and Prewitt filters, they were also defined 'incorrectly' according to this criterion. I also changed those. That may be a bit more controversial since a quick look on the web seemed to indicate that often it is defined the other around. If anybody thinks my changes are no good, please let me know. Cheers, Peter On 22 Sep, 2005, at 17:41, Alexandre Guimond wrote:
Hi.
I think I found a bug in gaussian_filter1d.
roughly the function creates a 1d kernel and then calls correlate1d. The problem I see is that the kernel should be mirrored prior to calling correlate1d since we want to convolve, not correlate.
as a result:
import numarray.nd_image numarray.nd_image.gaussian_filter1d( ( 0.0, 1.0, 0.0 ), 1, order = 1, axis = 0, mode = 'constant' ) array([0.24197145, 0. , 0.24197145])
when it should be [ 0.24197145, 0. , 0.24197145]) (notice the change in the sign of coefficients)
Or did I get that wrong?
alex.
participants (2)

Alexandre Guimond

Peter Verveer