Locating local maxima of arbitrary curve

I need to locate the local maxima across a histogram. That is, I need to locate the 'hills' in the histogram graph. Is the best way to do this to calculate the first derivative across the curve until it is under some low (near zero) threshold value? The graph can be quite noisy so I'm not sure what the best way to do this is. Also, what size window should be used to calculate the derivative across the points of the arbitrary curve?

Thanks in advance
LVL 5
corey_mcmAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
That's one way to do it.
A local maximum would then be where dOne goes from positive to negative
0
 
ozoCommented:
If the function is continuously differentiable the local maxima will be where the derivative is 0 and the second derivative is negative
0
 
ozoCommented:
If the function is discrete, than anywhere f(n-1) <  f(n) > f(n+1) is a local maximum
0
 
corey_mcmAuthor Commented:
I'm generating a critically smoothed gaussian kernel of the histogram.. Is the safe to use the following (where 'value' is the histogram array):

To calculate the first order derivative:

dOne (int x) {
    return value[i+1] - value[i];
}

To calculate the second order derivative:

dTwo (int x) {
    return dOne(x+1) - dOne(x);
}
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.