A grayscale image is a grid of integers img. Blur it: every cell in the new grid becomes the
average of the original cell and all of its neighbours (up to eight, including diagonals) that lie
inside the image, rounded down. Cells outside the image are ignored, not treated as zero.
Examples
Input: img = [[4, 0, 4],
[0, 8, 0],
[4, 0, 4]]
Output: [[3, 2, 3],
[2, 2, 2],
[3, 2, 3]]
Explanation: the corner (0,0) averages 4, 0, 0, 8 -> 12 // 4 = 3; the top-middle cell averages
six cells summing to 16 -> 16 // 6 = 2; the centre averages nine cells summing to 24 -> 24 // 9 = 2.
Input: img = [[10, 20],
[30, 40],
[50, 60]]
Output: [[25, 25],
[35, 35],
[45, 45]]
Constraints
1 <= rows, cols <= 100,0 <= img[r][c] <= 255- The input must not be modified. One test calls
img_after(img), which runs yoursmoothand then returnsimgitself, so it must come back unchanged.
Goals
- Average a cell with its existing 8-directional neighbours
- Use floor division and count only cells that exist