for finding peak. i tried findpeaks(). but its not working
3 次查看(过去 30 天)
显示 更早的评论
for the given
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154072/image.jpeg)
waveform
2 个评论
Adam
2014-8-6
You need to give more information really. In what way does it not work? Assuming the waveform you show there is in discrete form in an array I would think findpeaks should work ok.
I sometimes find myself wanting to write my own peak-finding algorithm after trying findpeaks, but that usually comes from me identifying something specific about its output that I don't like and can't seem to paramaterise well enough to give what I want. For a general case it should be fine though.
Image Analyst
2014-8-6
So now you have two threads on the same question. Why did you want that? What was wrong with your original discussion you had started in http://www.mathworks.com/matlabcentral/answers/146486-hi-i-have-a-signal-i-want-to-calculate-peak-and-area-of-the-signal
回答(2 个)
Nir Rattner
2014-8-6
编辑:Nir Rattner
2014-8-6
Assuming that the image provided is the input format for the signal, you can use the “find” function with a threshold to get all of the black pixels which represent the signal. You may need to use the “smooth” function to get remove some of the unwanted blurriness and noise from the signal. At that point you can simply use the “findpeaks” function with the “y” data:
I = imread('PPG.jpg');
% Threshold to pull signal pixels
[y, x] = find(I(:, :, 1) < 150);
% Smooth to remove image artifacts
ySmooth = size(I, 1) - smooth(x, y, 0.02);
plot(x, ySmooth, 'r');
hold on;
axis equal;
% Find peaks of Y Data
[peaks, locations] = findpeaks(ySmooth);
plot(x(locations), ySmooth(locations), 'o');
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!