an algorithm with O(nlogn) complexity for finding peaks of 2-d matrices