The matrix img stores grayscale values. Create a new matrix with the same dimensions. For each position, average its original value with every original value at most one row and one column away, including diagonal neighbors, and round the result down to an integer. Ignore positions outside the matrix, counting only cells that exist. Compute all averages from the original matrix, then return the resulting matrix.
Example 1:
Input: img = [[7]]
Output: [[7]]Explanation: Only the cell itself exists in its neighborhood, so its average remains 7.
Example 2:
Input: img = [[0,9,0]]
Output: [[4,3,4]]Explanation: The left and right cells each average two values, giving floor(9/2) = 4. The middle cell averages all three original values, giving 9/3 = 3. The result is [[4,3,4]].
Example 3:
Input: img = [[0,4],[8,12]]
Output: [[6,6],[6,6]]Explanation: Every cell sees all four original values. Their average is (0 + 4 + 8 + 12)/4 = 6, so all four output cells contain 6.
Constraints:
1 <= img.length <= 200- Every row has the same length, between
1and200. 0 <= img[i][j] <= 255