# @lc code=start classSolution: defimageSmoother(self, M: List[List[int]]) -> List[List[int]]: m = len(M[0]) N = [[0.1] + i + [0.1] for i in M] N = [[0.1] * (m + 2)] + N + [[0.1] * (m + 2)] for i inrange(1, len(N)-1): for j inrange(1, len(N[0])-1): total = [N[i-1][j-1],N[i-1][j],N[i-1][j+1], N[i][j-1],N[i][j],N[i][j+1], N[i+1][j-1],N[i+1][j],N[i+1][j+1]] sums, cnt = 0,0 for _ in total: if _ != 0.1: sums += _ cnt += 1 M[i-1][j-1] = int(sums / cnt) return M