How do I find the maximum and minimum of a histogram in MATLAB?
Ältere Kommentare anzeigen
I want to find max and min of a histogram in matlab please advise me. thanks
4 Kommentare
What does this mean?
If you have the data that created the histogram then it's simply min()/max() of that data. If you don't, then all you have is the bin boundaries and all you can say is that the values are within them.
This, of course, means that there were no values outside the range of the last bin edge that were ignored (as histc does if don't use inf for range). And, if there weren't such samples ignored, there's no way of knowing if those extreme value(s) were/were not included in the first/last bins.
Once a histogram has been formed there's a loss of information that is simply irretrievable w/o the raw data.
roya a
am 29 Jul. 2013
dpb
am 29 Jul. 2013
Again, too nebulous. What do you mean "maximum value of the intensity axes"?
You mean the maximum bin count? If so, if you used either hist or histc then it's just max|min on the returned counts vector.
If something else, explain what.
roya a
am 29 Jul. 2013
Antworten (4)
Image Analyst
am 29 Jul. 2013
[pixelCounts, grayLevels] = imhist(grayImage);
minGrayLevel = min(grayImage(:));
maxGrayLevel = max(grayImage(:));
% or
minGrayLevel = find(pixelCounts > 0, 1, 'first');
maxGrayLevel = find(pixelCounts > 0, 1, 'last');
minCounts = min(pixelCounts(:));
maxCounts = max(pixelCounts(:));
1 Kommentar
roya a
am 29 Jul. 2013
Oliver Herbage
am 25 Okt. 2016
2 Stimmen
Using the function 'histogram.m' H = histogram(X) will plot a histogram and return details to 'H'
'H.Values' returns a vector of the values from these details and the max and min functions can then be used on this to obtain the max and min of the histogram (e.g. 'max(H.Values)' and 'min(H.Values)')
Sean de Wolski
am 29 Jul. 2013
doc min
doc max
doc histc
doc min % and/or max
Look at alternate (optional) returns.
Kategorien
Mehr zu Histograms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!