Local extrema detecting