[SciPy-User] How to find local minimum of 1d histogram

Robin robince@gmail....
Fri Nov 27 14:12:20 CST 2009


On Fri, Nov 27, 2009 at 7:49 PM, Michael Aye
<kmichael.aye@googlemail.com> wrote:
> Hi!
>
> I am still fairly new with scipy, so please forgive me, if this is a
> simple question. But I couldn't find an example for this.
>
> What is the easiest way of finding the local minimum between 2
> gaussian-like peaks in a 1d Histogram?
>
> Background:
> Using a histogram on an image to identify 2 populations of
> intensities.
> The minimum between the gaussian-like peaks in the histogram shall be
> used as the masking limit to either show one or the other population
> of pixel intensities.
>
> My idea so far, but I'm not sure, if there is not a more obvious way?
> * Using interpolate1d to get a spline.
> * somehow get the coefficients of the spline function.
> * put them into poly1d
> * do derivative
> * get roots of derivative
>
> I am ready to go this way, but I wondered if it isn't easier?

>From the histogram you get a vector of counts - couldn't you do a diff
on the vector and look for where that changes sign? If its a bit noisy
you could look for where it changes sign or perhaps smooth before
diffing.

Cheers

Robin


More information about the SciPy-User mailing list