Skip to content

Commit

Permalink
division in local filter ensures no zero division is done
Browse files Browse the repository at this point in the history
  • Loading branch information
ronshnapp committed Nov 10, 2024
1 parent 7b43ab6 commit 033249c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions myptv/segmentation_mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from numpy import sum as npsum
from numpy import abs as npabs
from numpy import median as npmedian
from numpy import array
from numpy import array, divide, zeros_like
from numpy import append as npappend

from skimage.io import imread
Expand Down Expand Up @@ -120,7 +120,9 @@ def local_filter(self, image):

blur = gaussian_filter(num*num, S)
den = blur**0.5
normed = num / den
# normed = num / den
# to ensure no accidental zero division
normed = divide(num, den, out = zeros_like(num), where = (den != 0.0))

return image * (normed>1)

Expand Down

0 comments on commit 033249c

Please sign in to comment.