From aa6c444e134c892d568f48bf300d84481856815f Mon Sep 17 00:00:00 2001 From: Alex Liberzon Date: Thu, 2 May 2024 00:59:41 +0300 Subject: [PATCH] Update filters.py --- openpiv/filters.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openpiv/filters.py b/openpiv/filters.py index e5433ed8..386fdcf6 100644 --- a/openpiv/filters.py +++ b/openpiv/filters.py @@ -44,8 +44,13 @@ def _gaussian_kernel(half_width: int=1)-> np.ndarray: """ # size = int(half_width) - x, y = np.mgrid[-half_width:half_width + 1, -half_width:half_width + 1] - g = np.exp(-(x ** 2 / float(half_width) + y ** 2 / float(half_width))) + + if half_width == 0: + return 1 + else: + x, y = np.mgrid[-half_width:half_width + 1, -half_width:half_width + 1] + g = np.exp(-(x ** 2 / float(half_width) + y ** 2 / float(half_width))) + return g / g.sum()