How to count hight intensity points from improfile
1 次查看(过去 30 天)
显示 更早的评论
I wanted to count the high peaks as seen in image. this is the result of improfile() function of a binarized image.
0 个评论
回答(3 个)
Alexandre Turenne
2019-11-22
编辑:Alexandre Turenne
2019-11-22
look for 1s or 0.99 (idk if your function reaches 1) in the vector c
This wouldn't count the number of peaks but tell you how many times it is equal to 1
For counting the peaks I would do a rolling window. Something like that:
length_window_dist = 20 %nb of distance to look back
nb_peaks = 0
for i=1:length(c)
if c(i) == 1
%part i < initial window
if i<=length_window_dist && nb_peaks == 0
nb_peaks = nb_peaks+1
%part where i>intial window
else
% we dont want to see a 1 in the 20 last periods
if nnz(c(i-length_window_dist:i-1)==1) == 0 %lookback for the rolling window if c =1
nb_peaks = nb_peaks+1
end
end
end
end
there is surely a more efficient way to do this
0 个评论
Walter Roberson
2019-11-22
diff(values > some_threshold)
This will be:
- 1 at every leading edge of a rise (true minus false)
- -1 at every trailing edge of a rise (false minus true)
- 0 outside the rises (false minus false)
- 0 inside the rises (true minus true)
So to count peaks, count the 1's.
"Your threshold should be chosen taking into consideration how you want to treat those double peaks. If you want to count them together as a single event, set the threshold below the minimum that shows up between joined peaks -- assuming that the join is above the baseline. If you want to count the dual peaks as seperate events, set the threshold above about 0.7
Your data just after 500 might present some problems.
0 个评论
Image Analyst
2019-11-22
编辑:Image Analyst
2019-11-22
Try this:
[~, numPeaks] = bwlabel(yourProfile > 0.7);
1 个评论
Image Analyst
2019-11-22
If you want to combine short, close-together peaks, you can use the imdilate() function.
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!