[Numpy-discussion] Error in nd_image filters?
Russel Howe
russel at appliedminds.net
Fri Jun 3 11:44:21 EDT 2005
I think there is an error in the 2nd and 3rd derivative gaussian
kernels in the nd_image module. I have attached a patch which I
believe has the correct formula, would someone please double-check me
on this?
Thanks
Russel Howe
--- numarray-1.3.2/Packages/nd_image/Lib/filters.py 2005-03-08
15:58:08.000000000 -0800
+++ numarray-1.3.2-modified/Packages/nd_image/Lib/filters.py
2005-05-05 15:52:00.000000000 -0700
@@ -189,7 +189,7 @@
weights[lw] = -1.0
for ii in range(1, lw + 1):
x = float(ii)
- tmp = (2.0 * x * x / sd - 1.0) * weights[lw + ii]
+ tmp = ( x * x / sd - 1.0 ) * weights[lw + ii] / sd
weights[lw + ii] = tmp
weights[lw - ii] = tmp
elif order == 3: # third derivative
@@ -197,7 +197,7 @@
sd2 = sd * sd
for ii in range(1, lw + 1):
x = float(ii)
- tmp = (6.0 - 4.0 * x * x / sd) * x * weights[lw + ii]
+ tmp = (3.0 - x * x / sd) * x * weights[lw + ii] / sd / sd
weights[lw + ii] = tmp
weights[lw - ii] = -tmp
return correlate1d(input, weights, axis, origin = 0, mode = mode,
More information about the NumPy-Discussion
mailing list