How to count the total number of blink?
2 次查看(过去 30 天)
显示 更早的评论
Hi, I'm doing research on how count total number of blinks, is there any good resource for this task?
Thank You
0 个评论
采纳的回答
Bora Eryilmaz
2022-12-21
编辑:Bora Eryilmaz
2022-12-21
You can use a peak detection algorithm such as the islocalmax() command: https://www.mathworks.com/help/matlab/ref/islocalmax.html
x = randn(100,1);
plot(x)
hold on
level = 1.0;
yline(level, 'r')
% Only find peaks above the level.
I = (x < level);
x(I) = 0;
% Indices of all peaks above level.
J = islocalmax(x);
count = sum(J) % Number of peaks
plot(find(J), x(J), 'ro')
% Indices of the peaks above level that are at least 5 x-units apart.
J = islocalmax(x, 'MinSeparation', 5);
count = sum(J) % Number of peaks
plot(find(J), x(J), 'bx')
hold off
5 个评论
更多回答(1 个)
Image Analyst
2022-12-21
Not sure what "detect" means to you. But if the red line is your threshold and signals above the threshold are a blink, then you can count them with bwlabel". If you want to know what indexes contains a blink signal, you can use regionprops.
signal = rand(1, 200); % Sample signal
plot(signal, 'b-');
grid on;
xlabel('Index');
ylabel('Signal');
threshold = 0.9;
yline(threshold, 'Color', 'r', 'LineWidth',2)
binarySignal = signal > threshold;
[~, numBlinks] = bwlabel(binarySignal);
% If you want indexes of the blink runs, then you can use regionprops
props = regionprops(binarySignal, 'PixelIdxList')
% Print them out
for k = 1 : numel(props)
theseIndexes = props(k).PixelIdxList;
fprintf('For region #%d, it has indexes : ', k)
fprintf('%d ', theseIndexes)
fprintf('\n')
end
4 个评论
Bora Eryilmaz
2022-12-21
编辑:Bora Eryilmaz
2022-12-21
The code in this answer would require the Image Processing Toolbox.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!