def detect_peaks(hist, count=2):
hist_copy = hist
peaks = len(argrelextrema(hist_copy, np.greater, mode="wrap")[0])
sigma = log1p(peaks)
print(peaks, sigma)
while (peaks > count):
new_hist = gaussian_filter(hist_copy, sigma=sigma)
peaks = len(argrelextrema(new_hist, np.greater, mode="wrap")[0])
if peaks < count:
peaks = count + 1
sigma = sigma * 0.5
continue
hist_copy = new_hist
sigma = log1p(peaks)
print(peaks, sigma)
return argrelextrema(hist_copy, np.greater, mode="wrap")[0]
评论列表
文章目录