How to set a threshold based on the values of an array vector ?
15 次查看(过去 30 天)
显示 更早的评论
hi experts, I want to set a threshold based on the percentage of values in an array vector(320*1), Thus the value with the highest percentage will be my threshold for future use.
I want to plot the histogram of this array while the Y-axis have the percentage of each value occured in the array vector.
Any help or an ideat about how to set a threshold, i really appreciate it !
回答(1 个)
Image Analyst
2017-5-7
Use the > operator:
aboveThresholdIndexes = yourSignal > someThresholdValue; % A logical vector.
% If you want to extract those points:
aboveThreshold = yourSignal(aboveThresholdIndexes);
I leave it up to you to computer someThresholdValue because we don't know exactly what "threshold based on the percentage of values in an array" means. Do you mean like a percentage of 320 (the number of values in the array), or do you somehow want to take into account the values of those elements, in which case cumsum() might help?
4 个评论
Image Analyst
2017-5-7
That's because you never defined someThresholdValue. If you need to determine it by looking at the histogram, then call the histogram function:
histogram(yourSignal);
Obviously, just like someThresholdValue, you need to replace yourSignal with the actual name of your variable, and of course you need to have defined it already.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Thresholding 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!