I've been playing with a few ways of classifying contiguous regions of a histogram as: 1) peak, 2) valley, or 3) in-between bit.
Global thresholding has worked minimally well for me so far, but I'm thinking that a better approach will be to classify peaks/valleys by a threshold of change, e.g. the derivative.
I've approximated the derivative at each point in the histogram from its neighboring points. Then I define extrema regions to be everything with a derivative less than some given threshold (e.g. the "flatish parts"). This seems to generally classify extrema (peaks+valleys), and points in-between, well for my application.
I run into a little trouble when further classifying the regions of extrema into peaks or valleys. Taking the 2nd order derivative is problematic when the data is jittery. The 2nd derivative test for concavity won't be consistent across a modestly jittery peak or valley.
Two questions follow from that:
- Am I on a good path here, or is there some other approach to peak/valley classification I aught to consider before continuing on this path?
- A solution to this problem seems to be a
smoothfunction on the data to generate a smoothly differentiable function, but in looking into this approach I note that ever higher order polynomial fits are increasingly likely to exhibit wavy behavior not unlike the original jitter in the data. So then, what is a good approach that would avoid this problem? E.g. how do I classify an entire extrema region as either peak or valley?