I'm looking for a way to generate the following sequence of numbers (which are the relative coordinates of a pixel's 8 neighbours, starting with the north-west pixel and ending with the west). The first number is the y-coordinate and the second is the x-coordinate:
y, x
_____
1, -1 // N-W
1, 0 // N
1, 1 // N-E
0, 1 // E
-1, 1 // S-E
-1, 0 // S
-1, -1 // S-W
0, -1 // W
I can dream up several ugly ways to accomplish this, such as just putting the coordinates in an array, but I'm wondering if there's a clean and efficient way I haven't thought of.
Edit: due to the way the algorithm I'm trying to implement is designed, the pixels must be iterated in that particular order (N-W to W).