How to find highest three peaks in histogram?

21 Ansichten (letzte 30 Tage)
Escalin Frency
Escalin Frency am 6 Okt. 2016
Kommentiert: Image Analyst am 8 Okt. 2016
I found histogram of an image.I want to find highest three peaks of the histogram and find its location to feed as input.How to do it using for loop?
  2 Kommentare
Gentian Zavalani
Gentian Zavalani am 6 Okt. 2016
Return data from hist function to a variable (y = hist(x,bin);) and use Peakfinder FileExchange submission to find local maximums.
Guillaume
Guillaume am 6 Okt. 2016
We're talking about histogram (of an image so imhist is better than the very outdated hist), so peakfinder (or findpeaks) are not appropriate as they find local maxima. I assume Escalin just want the location of the highest three values in the histogram (which may well be next to each other)

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Massimo Zanetti
Massimo Zanetti am 6 Okt. 2016
Use findpeaks built-in Matlab function. https://it.mathworks.com/help/signal/ref/findpeaks.html

Guillaume
Guillaume am 6 Okt. 2016
[counts, binlocation] = imhist(yourimage); %plus whatever option you used for imhist
[sortedcount, indices] = sort(count); %sort your histogram
peakvalues = sortedcount(1:3) %highest 3 count in the histogram
peaklocations = binlocation(indices(1:3)) %respective image intensities for these peaks
  3 Kommentare
Guillaume
Guillaume am 8 Okt. 2016
Absolutely Not! findpeaks is completely inappropriate for finding the highest three values of an histogram.
Image Analyst
Image Analyst am 8 Okt. 2016
Bearbeitet: Image Analyst am 8 Okt. 2016
That's why I asked him, in his duplicate question, to explain what he defines as peaks, since there is some ambiguity and different people can define peaks in different ways, like the 3 highest bins, or the bins at the centers of the three tallest "humps" in the histogram. We need to know which way he wants it.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by