Skip to content

Commit

Permalink
modifies prominence algo
Browse files Browse the repository at this point in the history
Former-commit-id: 76ee145
  • Loading branch information
bsavitzky committed Feb 7, 2024
1 parent 36b4fe2 commit 5c406dd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions py4DSTEM/utils/get_maxima.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import numpy as np
from scipy.ndimage import gaussian_filter
from scipy.signal import medfilt
#from scipy.signal import medfilt
from scipy.ndimage import median_filter
try:
import cupy as cp
except (ModuleNotFoundError, ImportError):
Expand Down Expand Up @@ -124,7 +125,15 @@ def filter_2D_maxima(
# Remove maxima which are too dim relative to local median
if minProminence > 0:
assert(_ar is not None), "Array for median filter wasn't passed"
med = medfilt(_ar,prominenceKernelSize)
#med = medfilt(_ar,prominenceKernelSize)
assert(prominenceKernelSize%2==1), f"prominenceKernelSize must be odd, not {prominenceKernelSize}"
pks = prominenceKernelSize
footprint = np.ones((pks,pks), dtype=bool)
footprint[1:-1,1:-1] = 0
med = median_filter(
_ar,
footprint = footprint
)
compare = maxima["intensity"] - med[
maxima['x'].astype(int),
maxima['y'].astype(int)
Expand Down

0 comments on commit 5c406dd

Please sign in to comment.