m
and n
.smooth_img
with dimensions m x n
and initialize all cells to 0
.img[i][j]
.
sum
and count
to 0
.(x, y)
around img[i][j]
.(x, y)
is a valid neighbor, add img[x][y]
to sum
and increment count
.sum / count
and store the floored value in smooth_img[i][j]
.smooth_img
.