描述
Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 surrounding cells and itself. If a cell has less than 8 surrounding cells, then use as many as you can.
Example 1:
1 | Input: |
Note:
- The value in the given matrix is in the range of [0, 255].
- The length and width of the given matrix are in the range of [1, 150].
分析
对图片进行平滑处理,这里的算法很简单,对每个点统计周围点的总数,然后除以点的总数即为该点的值。
解决方案1(Java)
1 | class Solution { |