Histogram based thresholding for reduction in computation
Afficher commentaires plus anciens
i am planning to use histcounts () function for histogram based threshold We know that histogram is a plot of pixel intensity vs frequency. My plan is to use the histcounts function to identify the pixel intensity for a particular drop in frequency for the first time in the histogram and use it as a threshold. eg: say if I execute function [N edges] = histcounts(I) on image I and I get frequency values N = 5000 2000 1000 150 20 5 3 0 1 5 3 0 0 2 and edges = 0 2.5 2.7 3.0 3.5 3.8 4.2 4.6 4.9 5.4 5.7 6.1 7.3 7.7 8.1 then how do I choose a threshold by observing the minimum frequency for the first time and selecting the corresponding edge as the threshold. (In the above case 0 is the minimum frequency. I want the pixel intensity when this zero frequency occurs for the first time)
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 5 Sep 2018
You can pass "N" into imregionalmin() to get local mins (dips) in the histogram. Then use find() to find the first dip, if that's what you want. Something like (untested)
% Find all local mins (dips) in the histogram shape:
minIndexes = imregionalmin(N);
% minIndexes is 1 at every index that is a valley/min/dip.
% Find the first min
indexOfFirstMin = find(minIndexes, 1, 'first');
% Get the bin edge there and make that the threshold.
thresholdValue = edges(indexOfFirstMin);
Catégories
En savoir plus sur Data Distribution Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!