问题描述
我有一个一维信号,我试图在其中找到峰值.我想完美地找到它们.
I've got a 1-D signal in which I'm trying to find the peaks. I'm looking to find them perfectly.
我目前正在做的:
import scipy.signal as signal
peaks = signal.find_peaks_cwt(data, np.arange(100,200))
以下是一个带有红点的图表,显示了find_peaks_cwt()
找到的峰值位置.
The following is a graph with red spots which show the location of the peaks as found by find_peaks_cwt()
.
如您所见,计算出的峰值不够准确.真正重要的是右手边的三个.
As you can see, the calculated peaks aren't accurate enough. The ones that are really important are the three on the right hand side.
我的问题:我如何使这个更准确?
更新:数据在这里:http://pastebin.com/KSBTRUmW
对于某些背景,我想要做的是定位图像中手指之间的空间.绘制的是手周围轮廓的 x 坐标.青色斑点 = 峰.如果有更可靠/更强大的方法,请发表评论.
For some background, what I'm trying to do is locate the space in-between the fingers in an image. What is plotted is the x-coordinate of the contour around the hand. Cyan spots = peaks. If there is a more reliable/robust approach this, please leave a comment.
推荐答案
已解决,解决方案:
首先过滤数据:
window = signal.general_gaussian(51, p=0.5, sig=20)
filtered = signal.fftconvolve(window, data)
filtered = (np.average(data) / np.average(filtered)) * filtered
filtered = np.roll(filtered, -25)
然后根据rapelpy 的回答使用angrelextrema.
Then use angrelextrema as per rapelpy's answer.
结果:
这篇关于scipy 信号 find_peaks_cwt 没有准确找到峰值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!