Compute local extrema (min/max)