Skip to content

Commit 402646e

Browse files
authored
Merge pull request OpenPIV#326 from alexlib/master
update filters.py
2 parents 713586c + bf98c9f commit 402646e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

openpiv/filters.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,13 @@ def _gaussian_kernel(half_width: int=1)-> np.ndarray:
4444
4545
"""
4646
# size = int(half_width)
47-
x, y = np.mgrid[-half_width:half_width + 1, -half_width:half_width + 1]
48-
g = np.exp(-(x ** 2 / float(half_width) + y ** 2 / float(half_width)))
47+
48+
if half_width == 0:
49+
return 1
50+
else:
51+
x, y = np.mgrid[-half_width:half_width + 1, -half_width:half_width + 1]
52+
g = np.exp(-(x ** 2 / float(half_width) + y ** 2 / float(half_width)))
53+
4954
return g / g.sum()
5055

5156

0 commit comments

Comments
 (0)