Tap here to switch tabs
Problem
Submissions

Problem: Image Smoother

med
30 min
Try to solve the Image Smoother problem.

Statement

Given an m x n integer matrix img representing a grayscale image, return a matrix of the same size where each cell is replaced by the average of the cell and all of its valid neighboring cells.

For each cell, consider the cells directly adjacent to it horizontally, vertically, and diagonally. Only include neighbors that lie within the bounds of img. The new value of a cell is the floor of the average of all included values.

Note: The floor of a value is the greatest integer less than or equal to that value.

Constraints:

  • m == img.length

  • n == img[i].length

  • 1 <= m, n <= 200

  • 0 <= img[i][j] <= 255

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Image Smoother

med
30 min
Try to solve the Image Smoother problem.

Statement

Given an m x n integer matrix img representing a grayscale image, return a matrix of the same size where each cell is replaced by the average of the cell and all of its valid neighboring cells.

For each cell, consider the cells directly adjacent to it horizontally, vertically, and diagonally. Only include neighbors that lie within the bounds of img. The new value of a cell is the floor of the average of all included values.

Note: The floor of a value is the greatest integer less than or equal to that value.

Constraints:

  • m == img.length

  • n == img[i].length

  • 1 <= m, n <= 200

  • 0 <= img[i][j] <= 255