Ask Your Question

Revision history [back]

I browsed this forum and no surprise - many people already asked similar questions. I will try and summarize what was accumulated over years because the task is useful. Everything rotates around the definition. What is a peak? The simplest case - just the global maximum. The next approximation - any local maximum that is any bin fitting the condition prev < curr > next.

image description

I use the illustration from http://answers.opencv.org/question/98365/find-peaks-in-histogram/ You see that this def. will render a lot of false results. An obvious improvement is preprocessing. Namely - smoothing the histogram. Only then it becomes unworkable at all. Smoothed top will be flat so you will get either prev<curr=next or="" prev="curr=next" or="" prev="curr">next. Anything but the condition in the definition. We can add a shift hist(i-s)<hist(i)&gt;hist(i+s), but="" then="" s="" becomes="" a="" parameter="" which="" is="" unknown.="" all="" in="" all="" the="" definition="" of="" what="" is="" peak="" is="" task="" dependent.="" as="" a="" benchmark="" one="" can="" take="" matlab="" findpeaks()="" function.="" it="" requires="" 2="" parameters:="" minimal="" distance="" between="" peaks="" and="" minimal="" peak="" height.="" the="" first="" addresses="" the="" problem="" of="" bimodal="" peak.="" we="" need="" to="" exclude="" local="" peaks,="" but="" in="" principle="" all="" of="" them="" are="" local.="" also="" the="" task="" of="" extracting="" local="" maxima="" pops="" up="" in="" hough="" transform="" so="" if="" somebody="" needs="" very="" much,="" he="" can="" look="" into="" source="" code="" how="" it="" is="" implemented.="" this="" is="" for="" 2d="" histogram.<="" p="">

I browsed this forum and no surprise - many people already asked similar questions. I will try and summarize what was accumulated over years because the task is useful. Everything rotates around the definition. What is a peak? The simplest case - just the global maximum. The next approximation - any local maximum that is any bin fitting the condition prev < curr > next.

image description

I use the illustration from http://answers.opencv.org/question/98365/find-peaks-in-histogram/ You see that this def. will render a lot of false results. An obvious improvement is preprocessing. Namely - smoothing the histogram. Only then it becomes unworkable at all. Smoothed top will be flat so you will get either prev<curr=next or="" prev="curr=next" or="" prev="curr">next. prev < curr = next or prev = curr = next or prev = curr > next. Anything but the condition in the definition. We can add a shift hist(i-s)<hist(i)&gt;hist(i+s), but="" then="" s="" becomes="" a="" parameter="" which="" is="" unknown.="" all="" in="" all="" the="" definition="" of="" what="" is="" peak="" is="" task="" dependent.="" as="" a="" benchmark="" one="" can="" take="" matlab="" findpeaks()="" function.="" it="" requires="" 2="" parameters:="" minimal="" distance="" between="" peaks="" and="" minimal="" peak="" height.="" the="" first="" addresses="" the="" problem="" of="" bimodal="" peak.="" we="" need="" to="" exclude="" local="" peaks,="" but="" in="" principle="" all="" of="" them="" are="" local.="" also="" the="" task="" of="" extracting="" local="" maxima="" pops="" up="" in="" hough="" transform="" so="" if="" somebody="" needs="" very="" much,="" he="" can="" look="" into="" source="" code="" how="" it="" is="" implemented.="" this="" is="" for="" 2d="" histogram.<="" p="">

I browsed this forum and no surprise - many people already asked similar questions. I will try and summarize what was accumulated over years because the task is useful. Everything rotates around the definition. What is a peak? The simplest case - just the global maximum. The next approximation - any local maximum that is any bin fitting the condition prev < curr > next.

image description

I use the illustration from http://answers.opencv.org/question/98365/find-peaks-in-histogram/ You see that this def. will render a lot of false results. An obvious improvement is preprocessing. Namely - smoothing the histogram. Only then it becomes unworkable at all. Smoothed top will be flat so you will get either prev < curr = next or prev = curr = next or prev = curr > next. Anything but the condition in the definition. We can add a shift hist(i-s)<hist(i)&gt;hist(i+s), but="" then="" s="" becomes="" a="" parameter="" which="" is="" unknown.="" all="" in="" all="" the="" definition="" of="" what="" is="" peak="" is="" task="" dependent.="" as="" a="" benchmark="" one="" can="" take="" matlab="" findpeaks()="" function.="" it="" requires="" 2="" parameters:="" minimal="" distance="" between="" peaks="" and="" minimal="" peak="" height.="" the="" first="" addresses="" the="" problem="" of="" bimodal="" peak.="" we="" need="" to="" exclude="" local="" peaks,="" but="" in="" principle="" all="" of="" them="" are="" local.="" also="" the="" task="" of="" extracting="" local="" maxima="" pops="" up="" in="" hough="" transform="" so="" if="" somebody="" needs="" very="" much,="" he="" can="" look="" into="" source="" code="" how="" it="" is="" implemented.="" this="" is="" for="" 2d="" histogram.<="" p=""> hist(i-s) < hist(i) > hist(i+s), but then s becomes a parameter which is unknown. All in all the definition of what is peak is task dependent. As a benchmark one can take MatLab findpeaks() function. It requires 2 parameters: minimal distance between peaks and minimal peak height. The first addresses the problem of bimodal peak. We need to exclude local peaks, but in principle all of them are local. Also the task of extracting local maxima pops up in Hough transform so if somebody needs very much, he can look into source code how it is implemented. This is for 2D histogram.

I browsed this forum and no surprise - many people already asked similar questions. I will try and summarize what was accumulated over years because the task is useful. Everything rotates around the definition. What is a peak? The simplest case - just the global maximum. The next approximation - any local maximum that is any bin fitting the condition prev < curr > next.

image description

I use the illustration from http://answers.opencv.org/question/98365/find-peaks-in-histogram/ You see that this def. will render a lot of false results. An obvious improvement is preprocessing. Namely - smoothing the histogram. Only then it becomes unworkable at all. Smoothed top will be flat so you will get either prev < curr = next or prev = curr = next or prev = curr > next. Anything but the condition in the definition. We can add a shift hist(i-s) hist(i - s) < hist(i) > hist(i+s), hist(i + s), but then s becomes a parameter which is unknown. All in all the definition of what is peak is task dependent. As a benchmark one can take MatLab findpeaks() function. It requires 2 parameters: minimal distance between peaks and minimal peak height. The first addresses the problem of bimodal peak. We need to exclude local peaks, but in principle all of them are local. Also the task of extracting local maxima pops up in Hough transform so if somebody needs very much, he can look into source code how it is implemented. This is for 2D histogram.