Eight Neighbours, Scattered

Images as DataEasy+10 XP+10

Eight Neighbours, Scattered

A colour photograph has shape 90×160×390 \times 160 \times 390×160×3: height ×\times× width ×\times× channels. That is 909090 rows, each 160160160 pixels long, with a red, a green and a blue value for every pixel.

To feed it to an ordinary layer, it is unrolled into one flat list:

  • row by row, top row first, each row from left to right;
  • each pixel's three values written together, in the order red, green, blue, before moving on to the next pixel.

Rows, columns and list positions are all counted from 000.

Now pick out the green value of the pixel at row 40, column 100. In the grid, that pixel has eight neighbours touching it: above, below, left, right and the four diagonals. Each of them has a green value of its own.

On average, how many positions away from the chosen green value do those eight neighbouring green values land in the flat list? The distance between two entries is the absolute difference of their positions.

Give your answer to 2 decimal places.

Hints

Solve it to unlock the solution

Once you get it right, the reasoning behind the answer shows up here.