From: zhang on
Hi :
I have a 2D map with a lot of peaks in it, it is a 2D array.My task is to find the peaks in the map and save the coordinates of them.
the array is like this:


4 6 9 8 7 5 4 1
5 6 20 20 30 4 7 8
2 3 50 60 20 2 3 5
8 9 20 30 20 2 5 6
2 5 1 2 3 2 5 8
6 9 8 7 5 4 1 5
5 6 20 20 20 30 40 7
2 3 10 50 50 20 20 3
8 9 10 20 30 20 20 5
2 5 1 2 3 5 5 8
then the peaks is:(2,3)and(7,4)

Is there a function to find these peaks,or some other ways to solve this problem?
From: Greg Heath on
On Jun 28, 10:20 pm, "zhang " <236459...(a)qq.com> wrote:
> Hi :
>    I have a 2D map with a lot of peaks in it, it is a 2D array.My task is to find the peaks in the map and save the coordinates of them.
> the array is like this:
>
>    4    6    9   8     7      5   4     1
>    5    6   20  20   30    4    7     8
>    2    3   50  60   20    2    3     5
>    8    9   20  30   20    2    5     6
>    2    5   1    2     3     2    5     8
>    6    9   8    7     5     4    1     5
>    5    6   20   20   20   30   40   7      
>    2    3   10   50   50   20   20   3    
>    8    9   10  20    30   20   20   5    
>    2    5   1     2     3     5    5    8
> then the peaks is:(2,3)and(7,4)
>
> Is there a function to find these peaks,or some other ways to solve this problem?

To visualize

contour(A)

To find peaks

Loop over interior points
If a point is larger than it's eight neighbors,
store its coordinates.

Hope this helps.

Greg