Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 814
  • Last Modified:

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
0
corey_mcm
Asked:
corey_mcm
  • 3
1 Solution
 
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
 
ozoCommented:
That's one way to do it.
A local maximum would then be where dOne goes from positive to negative
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now