find lowest neighbor matlab
Posted
by
user1812719
on Stack Overflow
See other posts from Stack Overflow
or by user1812719
Published on 2012-11-09T16:19:57Z
Indexed on
2012/11/09
17:00 UTC
Read the original article
Hit count: 180
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!
© Stack Overflow or respective owner