A local maximum in a 2D array can be defined as a value such that all it\'s 4 neighbours are less than or equal to it, ie, for a[i][j]
to be a local maximum,
Just a heads up, local maxima or minima of a 2D grid can be computed in O(nlgn) time using a divide and conquer strategy. This is a slightly better time bound than the brute force algorithm contained in the O(n^2) time complexity class. Furthermore, improvements can be made to the divide and conquer algorithm to obtain an O(n) algorithm for the 2D grid extrema finding.
Check out these notes on the theory behind such peak picking algorithms (I am sure their are more materials out there):
http://courses.csail.mit.edu/6.006/spring11/lectures/lec02.pdf