An **image smoother** is a `3 x 3` filter that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If one or more of the surrounding cells of a cell is not present, we do not consider it in the average.
Given an `m x n` integer matrix `img` representing the grayscale of an image, return the image after applying the smoother on each cell of it.
An image smoother is a 3 x 3 filter that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the average of the nine cells in the blue smoother). If one or more of the surrounding cells of a cell is not present, we do not consider it in the average.
Given an m x n integer matrix img representing the grayscale of an image, return the image after applying the smoother on each cell of it.
Example 1:
Input: {"img":[[1,1,1],[1,0,1],[1,1,1]]}
Output: [[0,0,0],[0,0,0],[0,0,0]]
Constraints:
m=img.length
n=img[i].length
1≤m,n≤200
0≤img[i][j]≤255
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"img":[[1,1,1],[1,0,1],[1,1,1]]}
Make an empty 3 x 3 result. Each output cell is the floor of the average of the input cells in its 3 x 3 window, using only the cells that exist.