class Solution {
public:
vector<vector<int>> imageSmoother(vector<vector<int>>& img) {
int m = img.size();
int n = img[0].size();
vector<vector<int>> rets(m, vector<int>(n));
for(int i = 0; i < m; ++i) {
for(int j = 0; j < n; ++j) {
int cnt = 0, sum = 0;
for(int k = -1; k <= 1; ++k) {
int x = i + k;
if(x < 0 || x >= m) continue;
for(int t = -1; t <= 1; ++t) {
int y = j + t;
if(y < 0 || y >= n) continue;
sum += img[x][y];
++cnt;
}
}
rets[i][j] = floor(sum * 1.0 / cnt);
}
}
return rets;
}
};