find lowest neighbor matlab
- by user1812719
I am trying to write a function
[offset,coffset]=findLowNhbr(map)
that for each pixel in a map finds the eight neighbors to the pixel, and returns two matrices with both the row and column offsets to the lowest neighbor (uses the numbers -1, 0 and 1). Border pixels are given 0 offsets for both the row and column, since they do not have neighbors.
Here is what I think the general plan for this function should be:
For each point, find the eight nearest neighbors.
If the neighbor is lower than the point, return -1
If the neighbor is at the same elevation as the point, return 0
If the neighbor is higher than the point, return +1
Store these offsets in two matrices.
I am at a complete loss as to where to start, so any advice or questions are welcome!